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

ru.tinkoff.kora.http.server.common.HttpServerResponseMapperModule Maven / Gradle / Ivy

There is a newer version: 1.1.15
Show newest version
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