public interface HttpServerResponse
Interface created to guide the development of the HttpResponse object.
Modifiers | Name | Description |
---|---|---|
static int |
HTTP_BAD_REQUEST |
|
static int |
HTTP_CREATED |
|
static int |
HTTP_ERROR |
|
static int |
HTTP_NOT_FOUND |
|
static int |
HTTP_OK |
|
static int |
HTTP_REDIRECT_SEE_OTHER |
|
static int |
HTTP_UNAUTHORIZED |
Type Params | Return Type | Name and description |
---|---|---|
|
public HttpServerResponse |
badRequest() |
|
public HttpServerResponse |
created() |
|
public HttpServerResponse |
error() |
|
public HttpServerResponse |
notFound() |
|
public HttpServerResponse |
ok() |
|
public void |
redirect(java.lang.String url) Perform a 303 redirect to another URL. |
|
public HttpServerResponse |
removeCookie(java.lang.String name) |
|
public void |
render(java.lang.String templateName) |
|
public void |
render(java.lang.String templateName, java.util.Map<java.lang.String, java.lang.Object> data) |
|
public void |
reroute(java.lang.String path) Restarts the router with the new path, preserving all headers, cookies, state and parameters. |
|
public void |
send(java.lang.String content, java.lang.String contentType) Send String content back to the client. |
|
public void |
send(java.lang.String content) |
|
public void |
send() Send a response back to the client. |
|
public void |
sendFile(java.lang.String fileName) Send a file back to the client. |
|
public void |
sendFile(java.lang.String fileName, java.lang.String contentType) Send a file back to the client. |
|
public void |
sendJson(java.lang.Object data) Send a JSON response to the client. |
|
public HttpServerResponse |
setContentType(java.lang.String contentType) Set the Content-Type header of the response. |
|
public HttpServerResponse |
setCookie(java.lang.String name, java.lang.String value) Create a cookie that lasts for a month. |
|
public HttpServerResponse |
setCookie(Cookie cookie) Create a cookie. |
|
public HttpServerResponse |
setHeader(java.lang.String name, java.lang.String value) |
|
public HttpServerResponse |
setStatusCode(int statusCode) Set the status code of the response. |
|
public HttpServerResponse |
setStatusMessage(java.lang.String statusMessage) |
|
public HttpServerResponse |
todo() |
|
public HttpServerResponse |
unauthorized() |
|
public io.vertx.core.http.HttpServerResponse |
unwrap() Use with caution as this method will be removed in future updates. |
Perform a 303 redirect to another URL.
url
- The URL to redirect to.Restarts the router with the new path, preserving all headers, cookies, state and parameters. It's equivalent to servlet forwarding and not an HTTP redirect.
path
- The path of the other handler.Send String content back to the client.
content
- The content to send.contentType
- A valid HTTP Content Type. See ContentTypes for common values.Send a response back to the client.
Send a file back to the client.
fileName
- The name of the file. Can be a classpath resource or an actual file on disk.Send a file back to the client.
fileName
- The name of the file. Can be a classpath resource or an actual file on disk.contentType
- A valid HTTP Content Type. See ContentTypes for common values.Send a JSON response to the client.
data
- The object to serialize.Set the Content-Type header of the response. Use one of the constants in ContentTypes or a custom valid content type.
contentType
- The Content-Type value.Create a cookie that lasts for a month. Common durations can be found as constants in the Cookie class.
name
- The name of the cookie.value
- The cookie's value.Create a cookie.
cookie
- An instance of Cookie. Create it by calling Cookie.create.Set the status code of the response. Common status codes can be found as HTTP_* constants of HttpServerResponse.
statusCode
- The HTTP status code.Use with caution as this method will be removed in future updates. If you find yourself using this method, make a note of your use case and submit a pull request to the main repo.