Response
Response represents the HTTP response that GOX will send to the client at the end of an request.
Through this API it is possible to control the status code, headers, cookies, readdresses and other aspects of the HTTP response.
If you want to know how to access the information received from the client, see the documentation of Request.
Structure
ctx.Response
├── DoneWith(status, component)
├── Redirect
├── Status
├── Headers
├── Cookies
└── ImportMap Lifecycle
The response remains modifiable until GOX begins to generate the content that will be sent to the client.
Once the response generation is started, its configuration is blocked to ensure the consistency of the result.
See the documentation for Lifecycle to know when Response may be changed and what are the restrictions during the processing of an request.
DoneWith()
DoneWith immediately complete the request using the indicated status code.
When the code corresponds to an error response, GOX will automatically run the handler configured for that state, if it exists.
To find out how to customize these responses see the documentation of Custom errors.
See the documentation for DoneWith to know all the details of its operation.
Redirect
Redirect groups all operations related to HTTP redirections.
See the documentation for Redirect to know the different types of redirection available and when to use each.
Status
Status allows to consult and modify the HTTP status code that will be sent to the client.
See the documentation for Status to know all available operations.
Headers
Headers allows to manage the HTTP headers of the response.
See the documentation for Headers to know how to set, consult and remove headers.
Cookies
Cookies allows to manage cookies that will be sent together with the response.
See the documentation for Cookies to know how to create, modify and remove cookies.
ImportMap
ImportMap allows to register import aliases for JavaScript modules used by the page.
If you use client frameworks, check the documentation of Customers to know how to integrate client modules into a GOX application.
See the documentation for ImportMap to know all available operations.
Best practices
- Configure the response before you start generating content.
- Use
DoneWith()where the request is to be completed immediately. - Use
Redirectonly where it is necessary to change the location of the requested resource. - Keep the headers and cookies related to the same response organized.
- Centralizes import aliases by
ImportMap.