ru.tinkoff.kora.http.server.common.HttpServerResponseMapperModule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of http-server-common Show documentation
Show all versions of http-server-common Show documentation
Kora http-server-common module
package ru.tinkoff.kora.http.server.common;
import ru.tinkoff.kora.http.common.HttpResponseEntity;
import ru.tinkoff.kora.http.common.body.HttpBody;
import ru.tinkoff.kora.http.server.common.handler.HttpServerResponseEntityMapper;
import ru.tinkoff.kora.http.server.common.handler.HttpServerResponseMapper;
import java.nio.ByteBuffer;
public interface HttpServerResponseMapperModule {
default HttpServerResponseMapper noopResponseMapper() {
return (ctx, request, r) -> r;
}
default HttpServerResponseMapper byteBufBodyResponseMapper() {
return (ctx, request, r) -> HttpServerResponse.of(200, HttpBody.octetStream(r));
}
default HttpServerResponseMapper byteArrayResponseMapper() {
return (ctx, request, r) -> HttpServerResponse.of(200, HttpBody.octetStream(r));
}
default HttpServerResponseMapper stringResponseMapper() {
return (ctx, request, r) -> HttpServerResponse.of(200, HttpBody.plaintext(r));
}
default HttpServerResponseMapper> httpServerResponseEntityMapper(HttpServerResponseMapper delegate) {
return new HttpServerResponseEntityMapper<>(delegate);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy