ResponseModule

PackageAxial.Hosting.AspNetCore
Successful responses returned by endpoint Flows.

Summary

NameSignatureSynopsis
Operations
jsonResponse.json statusCode codec valueStreams a trusted value as JSON through a compiled codec.
emptyResponse.empty statusCodeReturns an empty response with the supplied status code.
textResponse.text statusCode valueReturns a plain-text response.
htmlResponse.html statusCode htmlReturns an HTML response, such as a page or the fragment an htmx request swaps in.
redirectResponse.redirect statusCode locationReturns a redirect to another address.
withHeaderResponse.withHeader name value responseAdds a header to a response, replacing a value already set under that name.
nativeResponse.native resultReturns a host-native ASP.NET result unchanged.

Operations

kind:member

json

Response.json statusCode codec value
Member
Streams a trusted value as JSON through a compiled codec.

Parameters

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

Returns

IResult

Verification Examples

return Response.json 201 Signup.codec signup
kind:member

empty

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

Parameters

NameTypeDescription
statusCodeintThe successful HTTP status code.

Returns

IResult

Verification Examples

return Response.empty 204
kind:member

text

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

Parameters

NameTypeDescription
statusCodeintThe successful HTTP status code.
valuestringThe response text.

Returns

IResult

Verification Examples

return Response.text 200 "ready"
kind:member

html

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

Parameters

NameTypeDescription
statusCodeintThe HTTP status code.
htmlstringThe rendered HTML.

Returns

IResult

Verification Examples

return Response.html 200 (renderHtml page)
kind:member

redirect

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

Parameters

NameTypeDescription
statusCodeintThe redirect status: 303 after a form post, 302 or 307 for a temporary move, 301 or 308 for a permanent one.
locationstringThe address sent in the Location header.

Returns

IResult

Verification Examples

return Response.redirect 303 "/signups"
kind:member

withHeader

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

Parameters

NameTypeDescription
namestringThe header name.
valuestringThe header value.
responseIResultThe response to add the header to.

Returns

IResult

Verification Examples

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

native

Response.native result
Member
Returns a host-native ASP.NET result unchanged.

Parameters

NameTypeDescription
resultIResultThe result constructed through ASP.NET APIs.

Returns

IResult

Verification Examples

return Response.native (Results.Redirect "/login")