Something that answers an HTTP request: it reads the request and writes the whole response.
It is the single entry point between a server and the application.
Applications do not implement it: the web starter registers one, the
dispatcherHandler bean, which runs the filters, finds the controller
method and writes errors. The server calls it once per request, and so
does MockMvc in tests, which is how a test reaches the application
without a network. A HandlerMapping also returns one for each request
it accepts.
// Calling the application without a server, as MockMvc does.
final app = context.getBeanByName('dispatcherHandler') as HttpHandler;
final response = MockServerHttpResponse();
await app.handle(
MockServerHttpRequest(HttpMethod.get, '/api/books'),
response,
);
log.info(response.statusCode); // 200
Spring (Java): HttpHandler (Spring WebFlux; on the servlet stack the
server calls the DispatcherServlet).
- Implementers
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
handle(
ServerHttpRequest request, ServerHttpResponse response) → Future< void> -
Answers
requestby writing toresponse, and closes the response. The future completes when the answer is written. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited