Search in sources :

Example 1 with Setting

use of com.github.dreamhead.moco.setting.Setting 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());
}
Also used : DefaultMutableHttpResponse(com.github.dreamhead.moco.model.DefaultMutableHttpResponse) HttpResponseSetting(com.github.dreamhead.moco.HttpResponseSetting) Setting(com.github.dreamhead.moco.setting.Setting)

Aggregations

HttpResponseSetting (com.github.dreamhead.moco.HttpResponseSetting)1 DefaultMutableHttpResponse (com.github.dreamhead.moco.model.DefaultMutableHttpResponse)1 Setting (com.github.dreamhead.moco.setting.Setting)1