Package net.uiqui.embedhttp.api
Interface HttpResponse
- All Known Implementing Classes:
HttpResponseImpl
public interface HttpResponse
Class representing an HTTP response.
Contains details such as the status code, headers, and body.
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpResponse
Creates a new HTTP response with the status code 400 (Bad Request) and the specified body.static HttpResponse
Creates a new HTTP response with the status code 500 (Internal Server Error) and the specified body.static HttpResponse
notFound()
Creates a new HTTP response with the status code 404 (Not Found) and the specified body.static HttpResponse
ok()
Creates a new HTTP response with the status code 200 (OK) and the specified body.Sets the body of the response with a specific content type.setBody
(ContentType contentType, String body) Sets the body of the response with a specific content type.Sets a header for the response.setHeader
(HttpHeader name, String value) Sets a header for the response.static HttpResponse
Creates a new HTTP response with the status code 500 (Internal Server Error) and the specified body.static HttpResponse
withStatus
(int statusCode, String statusMessage) Creates a new HTTP response with the specified status code and message.static HttpResponse
withStatus
(HttpStatusCode statusCode) Creates a new HTTP response with the specified status code and default message.
-
Method Details
-
setHeader
Sets a header for the response.- Parameters:
name
- the header name as an enumvalue
- the header value
-
setHeader
Sets a header for the response.- Parameters:
name
- the header name as a stringvalue
- the header value
-
setBody
Sets the body of the response with a specific content type.- Parameters:
contentType
- the content typebody
- the body as a string
-
setBody
Sets the body of the response with a specific content type.- Parameters:
contentType
- the content type as a stringbody
- the body as a string
-
withStatus
Creates a new HTTP response with the specified status code and default message.- Parameters:
statusCode
- the HTTP status code- Returns:
- a new HttpResponse instance
-
withStatus
Creates a new HTTP response with the specified status code and message.- Parameters:
statusCode
- the HTTP status codestatusMessage
- the HTTP status message- Returns:
- a new HttpResponse instance
-
ok
Creates a new HTTP response with the status code 200 (OK) and the specified body.- Returns:
- a new HttpResponse instance
-
noContent
Creates a new HTTP response with the status code 500 (Internal Server Error) and the specified body.- Returns:
- a new HttpResponse instance
-
notFound
Creates a new HTTP response with the status code 404 (Not Found) and the specified body.- Returns:
- a new HttpResponse instance
-
badRequest
Creates a new HTTP response with the status code 400 (Bad Request) and the specified body.- Returns:
- a new HttpResponse instance
-
unexpectedError
Creates a new HTTP response with the status code 500 (Internal Server Error) and the specified body.- Returns:
- a new HttpResponse instance
-