ResponseModule

PackageAxial.Hosting.GenHttp
Successful responses returned by GenHTTP endpoint Flows.

Summary

NameSignatureSynopsis
Operations
jsonResponse.json status codec valueSerializes a trusted value as JSON through a compiled codec.
emptyResponse.empty statusReturns an empty response with the supplied status.
textResponse.text status valueReturns a plain-text response.
htmlResponse.html status htmlReturns an HTML response, such as a page or the fragment an htmx request swaps in.
redirectResponse.redirect status locationReturns a redirect to another address.
withHeaderResponse.withHeader name value (HttpResponse respond)Adds a header to a response, replacing a value already set under that name.
nativeResponse.native respondBuilds a host-native response plan from the current GenHTTP request.

Operations

kind:member

json

Response.json status codec value
Member
Serializes a trusted value as JSON through a compiled codec.

Parameters

NameTypeDescription
statusResponseStatusThe successful HTTP status.
codecJsonCodec<'model>The compiled codec for the trusted output type.
value'modelThe trusted output value.

Returns

HttpResponse

Verification Examples

return Response.json ResponseStatus.Created Signup.codec signup
kind:member

empty

Response.empty status
Member
Returns an empty response with the supplied status.

Parameters

NameTypeDescription
statusResponseStatusThe successful HTTP status.

Returns

HttpResponse

Verification Examples

return Response.empty ResponseStatus.NoContent
kind:member

text

Response.text status value
Member
Returns a plain-text response.

Parameters

NameTypeDescription
statusResponseStatusThe successful HTTP status.
valuestringThe response text.

Returns

HttpResponse

Verification Examples

return Response.text ResponseStatus.Ok "ready"
kind:member

html

Response.html status html
Member
Returns an HTML response, such as a page or the fragment an htmx request swaps in.

Parameters

NameTypeDescription
statusResponseStatusThe HTTP status.
htmlstringThe rendered HTML.

Returns

HttpResponse

Verification Examples

return Response.html ResponseStatus.Ok (renderHtml page)
kind:member

redirect

Response.redirect status location
Member
Returns a redirect to another address.

Parameters

NameTypeDescription
statusResponseStatusThe redirect status: SeeOther after a form post, Found or TemporaryRedirect for a temporary move, MovedPermanently or PermanentRedirect for a permanent one.
locationstringThe address sent in the Location header.

Returns

HttpResponse

Verification Examples

return Response.redirect ResponseStatus.SeeOther "/signups"
kind:member

withHeader

Response.withHeader name value (HttpResponse respond)
Member
Adds a header to a response, replacing a value already set under that name.

Parameters

NameTypeDescription
namestringThe header name.
valuestringThe header value.
HttpResponse respondHttpResponse

Returns

HttpResponse

Verification Examples

return
    Response.html ResponseStatus.Ok fragment
    |> Response.withHeader "HX-Push-Url" address
    |> Response.withHeader "HX-Trigger" "saved"
kind:member

native

Response.native respond
Member
Builds a host-native response plan from the current GenHTTP request.

Parameters

NameTypeDescription
respondIRequest -> IResponseThe host-specific response function.

Returns

HttpResponse

Verification Examples

return Response.native (fun request -> request.Respond().Build())