io.github.mike10004.vhs.bmp.HttpAssistant Maven / Gradle / Ivy
package io.github.mike10004.vhs.bmp;
import com.google.common.io.CharSource;
import com.google.common.net.MediaType;
import io.github.mike10004.vhs.HttpRespondable;
import io.github.mike10004.vhs.harbridge.ParsedRequest;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* Interface defining methods to interpret HTTP message objects.
* @param request type
* @param response type
*/
public interface HttpAssistant {
ParsedRequest parseRequest(RQ incomingRequest) throws IOException;
RS transformRespondable(RQ incomingRequest, HttpRespondable respondable) throws IOException;
RS constructResponse(RQ incomingRequest, ImmutableHttpResponse response);
static ImmutableHttpResponse standardServerErrorResponse() {
return ImmutableHttpResponse.builder(500)
.content(MediaType.PLAIN_TEXT_UTF_8, CharSource.wrap("500 Internal Server Error").asByteSource(StandardCharsets.UTF_8))
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy