Prettynice.Response
HTTP Responses
An HTTP response value.
Custom type for text-based response bodies.
Turn a Node HttpServer Response into a Prettynice Response.
You shouldn't need this in your normal application code. The response you get in a Prettynice request message is already a Prettynice Response.
Updating Responses
Set the status of the response.
Add a header to the response.
Set the body of the response directly.
Normally you can use one of the send*
functions,
but if you need more control, you can set a Body
directly.
Sending Responses
You can construct and send a Response
directly with send
,
or you can use one of the send*
helpers to send data with the content-type set automatically.
Command to send a response to the current HTTP request.
Respond with HTML.
title
will go into the <title>
tag,
head
will be added to the <head>
tag,
and body
will go into the <body>
tag.
Note that Prettynice uses and expects Html from icidasset/html-gren, not from gren-lang/browser. The API is the same, but html-gren is needed because it supports server-side rendering.
Respond with plain text.
Respond with Json.
Respond with raw bytes.
Use this to send binary data like files, images, etc.