ResponseModule
PackageAxial.Hosting.GenHttp
Successful responses returned by GenHTTP endpoint Flows.
Summary
| Name | Signature | Synopsis |
|---|---|---|
| Operations | ||
| json | Response.json status codec value | Serializes a trusted value as JSON through a compiled codec. |
| empty | Response.empty status | Returns an empty response with the supplied status. |
| text | Response.text status value | Returns a plain-text response. |
| html | Response.html status html | Returns an HTML response, such as a page or the fragment an htmx request swaps in. |
| redirect | Response.redirect status location | Returns a redirect to another address. |
| withHeader | Response.withHeader name value (HttpResponse respond) | Adds a header to a response, replacing a value already set under that name. |
| native | Response.native respond | Builds a host-native response plan from the current GenHTTP request. |
Operations
kind:member
Serializes a trusted value as JSON through a compiled codec.
Parameters
| Name | Type | Description |
|---|---|---|
| status | ResponseStatus | The successful HTTP status. |
| codec | JsonCodec<'model> | The compiled codec for the trusted output type. |
| value | 'model | The trusted output value. |
Returns
HttpResponse
Verification Examples
return Response.json ResponseStatus.Created Signup.codec signupkind:member
kind:member
kind:member
Returns an HTML response, such as a page or the fragment an htmx request swaps in.
Parameters
| Name | Type | Description |
|---|---|---|
| status | ResponseStatus | The HTTP status. |
| html | string | The rendered HTML. |
Returns
HttpResponse
Verification Examples
return Response.html ResponseStatus.Ok (renderHtml page)kind:member
Returns a redirect to another address.
Parameters
| Name | Type | Description |
|---|---|---|
| status | ResponseStatus | The redirect status: SeeOther after a form post, Found or TemporaryRedirect for a temporary move, MovedPermanently or PermanentRedirect for a permanent one. |
| location | string | The address sent in the Location header. |
Returns
HttpResponse
Verification Examples
return Response.redirect ResponseStatus.SeeOther "/signups"kind:member
Adds a header to a response, replacing a value already set under that name.
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The header name. |
| value | string | The header value. |
| HttpResponse respond | HttpResponse |
Returns
HttpResponse
Verification Examples
return
Response.html ResponseStatus.Ok fragment
|> Response.withHeader "HX-Push-Url" address
|> Response.withHeader "HX-Trigger" "saved"kind:member
Builds a host-native response plan from the current GenHTTP request.
Parameters
| Name | Type | Description |
|---|---|---|
| respond | IRequest -> IResponse | The host-specific response function. |
Returns
HttpResponse
Verification Examples
return Response.native (fun request -> request.Respond().Build())
