com.github.dreamhead.moco.handler.VersionResponseHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moco-core Show documentation
Show all versions of moco-core Show documentation
Moco is an easy setup stub framework, mainly focusing on testing and integration.
package com.github.dreamhead.moco.handler;
import com.github.dreamhead.moco.HttpProtocolVersion;
import com.github.dreamhead.moco.HttpRequest;
import com.github.dreamhead.moco.MutableHttpResponse;
import com.github.dreamhead.moco.resource.Resource;
public final class VersionResponseHandler extends AbstractHttpResponseHandler {
private final Resource resource;
public VersionResponseHandler(final Resource resource) {
this.resource = resource;
}
@Override
protected void doWriteToResponse(final HttpRequest httpRequest, final MutableHttpResponse httpResponse) {
String version = resource.readFor(httpRequest).toString();
httpResponse.setVersion(HttpProtocolVersion.versionOf(version));
}
}