Api Contract
A contract for an API endpoint shared between the client and server.
Parameters
The path of the API endpoint. Automatically prefixed with "api/".
The HTTP method to use for the API endpoint. Defaults to HttpMethod.POST.
The HeaderField to decode the request headers.
The HeaderField to decode the response headers.
The PathField to decode the path parameters.
The QueryField to decode the query parameters.
The CookieField to decode the request cookies.
The BodyFormat to use for the request body. Defaults to UnitFormat or JsonFormat.
The BodyFormat to use for the response body. Defaults to UnitFormat or JsonFormat.
Whether the API endpoint requires authentication. Defaults to false.
Type Parameters
The type of the request body. If the request body is empty, this should be Unit.
The type of the response body. If the response body is empty, this should be Unit.
The type of the request headers. Use Empty for no headers.
The type of the response headers. Use Empty for no headers.
The type of the path parameters. Use Empty for no path parameters.
The type of the query parameters. Use Empty for no query parameters.
The type of the request cookies. Use Empty for no cookies.
Constructors
Properties
Functions
Extension to make calling contracts more ergonomic.
Decodes the query parameters into the type QueryP.
Decodes the request headers into the type ReqH. Can be overridden to provide custom header decoding.
Decodes the response headers into the type ResH. Can be overridden to provide custom header decoding.
Creates a route for the given ApiContract.
Simplifies registration for ApiContract types with no path or query parameters.
Overload for register that allows returning Unit when the response body is Unit and headers are Empty.
Creates a route for the given ApiContract with a multipart request body.
Creates a route for the given ApiContract that returns a paginated response with a Pagination context.