Package akka.javasdk.http
Class HttpResponses
Object
akka.javasdk.http.HttpResponses
Helper class for creating common HTTP responses.
Provides factory method for creating HttpResponse object for the most common cases.
Returned HttpResponses can be enriched with additional headers, status codes, etc.
-
Method Summary
Modifier and TypeMethodDescriptionstatic akka.http.javadsl.model.HttpResponse
accepted()
Creates a 202 ACCEPTED response.static akka.http.javadsl.model.HttpResponse
Creates a 202 ACCEPTED response with an application/json body.static akka.http.javadsl.model.HttpResponse
Creates a 202 ACCEPTED response with a text/plain body.static akka.http.javadsl.model.HttpResponse
Creates a 400 BAD REQUEST response.static akka.http.javadsl.model.HttpResponse
badRequest
(String text) Creates a 400 BAD REQUEST response with a text/plain body.static akka.http.javadsl.model.HttpResponse
created()
Creates a 201 CREATED response.static akka.http.javadsl.model.HttpResponse
Creates a 201 CREATED response with an application/json body The passed Object is serialized to json using the application's default Jackson serializer.static akka.http.javadsl.model.HttpResponse
Creates a 201 CREATED response with an application/json body and a location header.static akka.http.javadsl.model.HttpResponse
Creates a 201 CREATED response with a text/plain body.static akka.http.javadsl.model.HttpResponse
Creates a 201 CREATED response with a text/plain body and a location header.static akka.http.javadsl.model.HttpResponse
Creates a 500 INTERNAL SERVER ERROR response.static akka.http.javadsl.model.HttpResponse
internalServerError
(String text) Creates a 500 INTERNAL SERVER ERROR response with a text/plain body.static akka.http.javadsl.model.HttpResponse
Creates a 204 NO CONTENT response.static akka.http.javadsl.model.HttpResponse
notFound()
Creates a 404 NOT FOUND response.static akka.http.javadsl.model.HttpResponse
Creates a 404 NOT FOUND response with a text/plain body.static akka.http.javadsl.model.HttpResponse
Creates a 501 NOT IMPLEMENTED response.static akka.http.javadsl.model.HttpResponse
notImplemented
(String text) Creates a 501 NOT IMPLEMENTED response with a text/plain body.static akka.http.javadsl.model.HttpResponse
of
(akka.http.javadsl.model.StatusCode statusCode, akka.http.javadsl.model.ContentType contentType, byte[] body) Creates an HTTP response with specified status code, content type and body.static akka.http.javadsl.model.HttpResponse
ok()
Creates a 200 OK response.static akka.http.javadsl.model.HttpResponse
Creates a 200 OK response with an application/json body.static akka.http.javadsl.model.HttpResponse
Creates a 200 OK response with a text/plain body.
-
Method Details
-
of
public static akka.http.javadsl.model.HttpResponse of(akka.http.javadsl.model.StatusCode statusCode, akka.http.javadsl.model.ContentType contentType, byte[] body) Creates an HTTP response with specified status code, content type and body.- Parameters:
statusCode
- HTTP status codecontentType
- HTTP content typebody
- HTTP body
-
ok
public static akka.http.javadsl.model.HttpResponse ok()Creates a 200 OK response. -
ok
Creates a 200 OK response with a text/plain body. -
ok
Creates a 200 OK response with an application/json body. The passed Object is serialized to json using the application's default Jackson serializer. -
created
public static akka.http.javadsl.model.HttpResponse created()Creates a 201 CREATED response. -
created
Creates a 201 CREATED response with a text/plain body. -
created
Creates a 201 CREATED response with a text/plain body and a location header. -
created
Creates a 201 CREATED response with an application/json body The passed Object is serialized to json using the application's default Jackson serializer. -
created
Creates a 201 CREATED response with an application/json body and a location header. The passed Object is serialized to json using the application's default Jackson serializer. -
accepted
public static akka.http.javadsl.model.HttpResponse accepted()Creates a 202 ACCEPTED response. -
accepted
Creates a 202 ACCEPTED response with a text/plain body. -
accepted
Creates a 202 ACCEPTED response with an application/json body. The passed Object is serialized to json using the application's default Jackson serializer. -
noContent
public static akka.http.javadsl.model.HttpResponse noContent()Creates a 204 NO CONTENT response. -
badRequest
public static akka.http.javadsl.model.HttpResponse badRequest()Creates a 400 BAD REQUEST response. -
badRequest
Creates a 400 BAD REQUEST response with a text/plain body. -
notFound
public static akka.http.javadsl.model.HttpResponse notFound()Creates a 404 NOT FOUND response. -
notFound
Creates a 404 NOT FOUND response with a text/plain body. -
internalServerError
public static akka.http.javadsl.model.HttpResponse internalServerError()Creates a 500 INTERNAL SERVER ERROR response. -
internalServerError
Creates a 500 INTERNAL SERVER ERROR response with a text/plain body. -
notImplemented
public static akka.http.javadsl.model.HttpResponse notImplemented()Creates a 501 NOT IMPLEMENTED response. -
notImplemented
Creates a 501 NOT IMPLEMENTED response with a text/plain body.
-