use of com.github.dreamhead.moco.model.DefaultMutableHttpResponse in project moco by dreamhead.
the class MocoHandler method doGetHttpResponse.
private DefaultMutableHttpResponse doGetHttpResponse(final HttpRequest request) {
DefaultMutableHttpResponse httpResponse = newResponse(request, DEFAULT_STATUS);
SessionContext context = new SessionContext(request, httpResponse);
for (Setting setting : settings) {
if (setting.match(request)) {
setting.writeToResponse(context);
return httpResponse;
}
}
if (anySetting.match(request)) {
anySetting.writeToResponse(context);
return httpResponse;
}
monitor.onUnexpectedMessage(request);
return newResponse(request, HttpResponseStatus.BAD_REQUEST.code());
}
use of com.github.dreamhead.moco.model.DefaultMutableHttpResponse in project moco by dreamhead.
the class MocoHandler method handleRequest.
private FullHttpResponse handleRequest(final FullHttpRequest message) {
HttpRequest request = DefaultHttpRequest.newRequest(message);
DefaultMutableHttpResponse httpResponse = getHttpResponse(request);
FullHttpResponse response = httpResponse.toFullResponse();
prepareForKeepAlive(message, response);
monitor.onMessageLeave(httpResponse);
return response;
}
Aggregations