replyWith method

void replyWith(
  1. AgEndpoint endpoint,
  2. Object? json(
    1. AgRequest request
    ), {
  3. AgHttpMethod method = AgHttpMethod.get,
  4. int statusCode = 200,
  5. Map<String, List<String>> headers = const {},
})

Like reply, but builds the body from each request — to echo a posted body back, or to answer per path parameter.

Implementation

void replyWith(
  AgEndpoint endpoint,
  Object? Function(AgRequest request) json, {
  AgHttpMethod method = AgHttpMethod.get,
  int statusCode = 200,
  Map<String, List<String>> headers = const {},
}) {
  _replies[_key(method, endpoint)] = _Reply(
    json: json,
    statusCode: statusCode,
    headers: headers,
  );
}