All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dreamhead.moco.handler.AbstractHttpResponseHandler Maven / Gradle / Ivy

Go to download

Moco is an easy setup stub framework, mainly focusing on testing and integration.

There is a newer version: 1.5.0
Show newest version
package com.github.dreamhead.moco.handler;

import com.github.dreamhead.moco.HttpRequest;
import com.github.dreamhead.moco.MutableHttpResponse;
import com.github.dreamhead.moco.Request;
import com.github.dreamhead.moco.Response;
import com.github.dreamhead.moco.internal.SessionContext;

public abstract class AbstractHttpResponseHandler extends AbstractResponseHandler {
    protected abstract void doWriteToResponse(HttpRequest httpRequest, MutableHttpResponse httpResponse);

    @Override
    public void writeToResponse(final SessionContext context) {
        Request request = context.getRequest();
        Response response = context.getResponse();

        if (HttpRequest.class.isInstance(request) && MutableHttpResponse.class.isInstance(response)) {
            HttpRequest httpRequest = HttpRequest.class.cast(request);
            MutableHttpResponse httpResponse = MutableHttpResponse.class.cast(response);
            doWriteToResponse(httpRequest, httpResponse);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy