ru.tinkoff.kora.http.common.HttpResponseEntity Maven / Gradle / Ivy
The newest version!
package ru.tinkoff.kora.http.common;
import jakarta.annotation.Nullable;
import ru.tinkoff.kora.http.common.header.HttpHeaders;
import ru.tinkoff.kora.http.common.header.MutableHttpHeaders;
/**
* Русский: Описывает HTTP ответ как сущность с метаинформацией о коде ответа и заголовках
*
* English: Describes an HTTP response as an entity with meta-information about the response code and headers
*
*
* Пример / Example:
*
* {@code
* HttpResponseEntity.of(200, "OK")
* }
*
*/
public interface HttpResponseEntity {
int code();
MutableHttpHeaders headers();
@Nullable
T body();
static HttpResponseEntity of(int code, T body) {
return new HttpResponseEntityImpl<>(code, HttpHeaders.of(), body);
}
static HttpResponseEntity of(int code, MutableHttpHeaders headers, T body) {
return new HttpResponseEntityImpl<>(code, headers, body);
}
}