forwardInternal method

Future<JsonFormBody> forwardInternal({
  1. required String method,
  2. required String path,
  3. Map<String, String> query = const <String, String>{},
  4. List<int> body = const <int>[],
  5. String? contentType,
  6. Map<String, String> extraHeaders = const <String, String>{},
})

Forwards an internal route request to the remote server.

Used by SatoriServer._handleInternal when a global route (/_tmp/:id, /_api/:name) misses locally and the real handler lives on the remote side. Returns the remote response verbatim — status, headers and bytes — so the local server can mirror it (including 404/405 and pagination headers). Auth token and identity headers ride along via NitoriClient.

Implementation

Future<JsonFormBody> forwardInternal({
  required String method,
  required String path,
  Map<String, String> query = const <String, String>{},
  List<int> body = const <int>[],
  String? contentType,
  Map<String, String> extraHeaders = const <String, String>{},
}) {
  final internalUrl = getInternalUrl(
    path,
    query: query.isEmpty ? null : query,
    slash: true,
  );
  return _remoteBot.forwardFullPathBytes(
    internalUrl,
    body,
    method: method,
    contentType: contentType,
    extraHeaders: {
      ...extraHeaders,
      'satori-platform': _remoteBot.platform,
      'satori-user-id': _remoteBot.userId,
    },
  );
}