offstage
Types
pub type BadRequestResponse {
BadRequestResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
BadRequestResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
The type representing Bearer authentication in the system
pub type BearerAuth {
BearerAuth(token: String)
}
Constructors
-
BearerAuth(token: String)
pub type ConflictResponse {
ConflictResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
ConflictResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
pub type InternalServerErrorResponse {
InternalServerErrorResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
InternalServerErrorResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
The type representing a JSON response from the server
pub type JsonResponse(response) {
JsonResponse(
apply: fn(response) -> response.Response(wisp.Body),
apply_when: fn(
response,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
JsonResponse( apply: fn(response) -> response.Response(wisp.Body), apply_when: fn( response, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
The response type for Mist.
pub type MistResponse =
offstage_core.MistResponse
pub type NotFoundResponse {
NotFoundResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
NotFoundResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
pub type OpenAPIScope =
offstage_core.OpenAPIScope
The common request type that supports both Wisp and Mist.
pub type Request =
request.Request(offstage_core.Connection)
pub type RouteCapability(data, object) =
offstage_core.RouteCapability(data, object)
pub type RouteSpec =
offstage_core.RouteSpec
pub type RouteSpecBuilder =
offstage_core.RouteSpecBuilder
pub type ServiceUnavailableResponse {
ServiceUnavailableResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
ServiceUnavailableResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
pub type TimeoutResponse {
TimeoutResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
TimeoutResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
pub type UnauthorizedResponse {
UnauthorizedResponse(
apply: fn(String) -> response.Response(wisp.Body),
apply_when: fn(
String,
Bool,
fn() -> response.Response(wisp.Body),
) -> response.Response(wisp.Body),
)
}
Constructors
-
UnauthorizedResponse( apply: fn(String) -> response.Response(wisp.Body), apply_when: fn( String, Bool, fn() -> response.Response(wisp.Body), ) -> response.Response(wisp.Body), )
The response type for Wisp.
pub type WispResponse =
response.Response(wisp.Body)
Values
pub fn bad_request(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(BadRequestResponse, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn bearer_auth(
spec: offstage_core.RouteSpecBuilder,
name: String,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(BearerAuth, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
Add bearer authentication to the route.
pub fn build(
spec: offstage_core.RouteSpecBuilder,
builder: fn(request.Request(offstage_core.Connection)) -> Result(
object,
response.Response(wisp.Body),
),
route: fn(request.Request(offstage_core.Connection), object) -> response.Response(
wisp.Body,
),
) -> offstage_core.RouteSpec
Build a route specification from the given builder functions.
pub fn conflict(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(ConflictResponse, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn delete(route: String) -> offstage_core.RouteSpecBuilder
Create a DELETE route with the given [route] path.
pub fn description(
spec: offstage_core.RouteSpecBuilder,
description: String,
) -> offstage_core.RouteSpecBuilder
Set the [summary] of the route.
pub fn doc(
spec: offstage_core.RouteSpec,
openapi: openapi.OpenAPI,
) -> openapi.OpenAPI
Get the OpenAPI document from the given route definition
pub fn get(route: String) -> offstage_core.RouteSpecBuilder
Create a GET route with the given [route] path.
pub fn internal_server_error(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(
InternalServerErrorResponse,
object,
),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn json_body(
spec: offstage_core.RouteSpecBuilder,
decoder: serialize.Decoder(body),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(body, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
Add a json body with the given decoder to the route
pub fn json_path_parameter(
spec: offstage_core.RouteSpecBuilder,
name: String,
decoder: serialize.Decoder(a),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(a, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn json_query_parameter(
spec: offstage_core.RouteSpecBuilder,
name: String,
serializer: serialize.Serializer(a),
default: option.Option(a),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(a, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn json_response(
spec: offstage_core.RouteSpecBuilder,
code: Int,
summary: String,
encoder: serialize.Encoder(response),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(JsonResponse(response), object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn match_path_segment(
request_segments: List(String),
route_segments: List(String),
) -> Bool
Verify if the given request segments match the route’s segments. Parameters like ‘{id}’ will be treated as wildcards.
pub fn multipart_body(
spec: offstage_core.RouteSpecBuilder,
decoder: serialize.Decoder(body),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(body, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
Add a multipart body with the given decoder to the route
pub fn not_found(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(NotFoundResponse, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn pagination(
spec: offstage_core.RouteSpecBuilder,
config: pagination.PaginationConfig(
a,
b,
offstage_core.Connection,
),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(a, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn patch(route: String) -> offstage_core.RouteSpecBuilder
Create a PATCH route with the given [route] path.
pub fn path_parameter(
spec: offstage_core.RouteSpecBuilder,
name: String,
decoder: serialize.Decoder(a),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(a, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn post(route: String) -> offstage_core.RouteSpecBuilder
Create a POST route with the given [route] path.
pub fn put(route: String) -> offstage_core.RouteSpecBuilder
Create a PUT route with the given [route] path.
pub fn query_parameter(
spec: offstage_core.RouteSpecBuilder,
name: String,
serializer: serialize.Serializer(a),
default: option.Option(a),
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(a, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn require_authorization(
req: request.Request(offstage_core.Connection),
unauthorized: UnauthorizedResponse,
) -> Result(String, response.Response(wisp.Body))
Require the given token from the request headers and execute the given function accordingly
pub fn router(
openapi: openapi.OpenAPI,
specs: List(offstage_core.RouteSpec),
request: request.Request(offstage_core.Connection),
) -> response.Response(wisp.Body)
Route the request to the corresponding route based on the given specs.
pub fn service_unavailable(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(
ServiceUnavailableResponse,
object,
),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub fn summary(
spec: offstage_core.RouteSpecBuilder,
summary: String,
) -> offstage_core.RouteSpecBuilder
Set the [summary] of the route.
pub fn tag(
spec: offstage_core.RouteSpecBuilder,
tag: String,
) -> offstage_core.RouteSpecBuilder
Set the [tag] of the route.
pub fn timeout(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(TimeoutResponse, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec
pub const try: fn(Result(a, b), fn(a) -> b) -> b
Attempt to execute the given function with the value inside the Result. This function is
similar to the result.try function, returning the
pub fn unauthorized(
spec: offstage_core.RouteSpecBuilder,
next: fn(
offstage_core.RouteSpecBuilder,
offstage_core.RouteCapability(UnauthorizedResponse, object),
) -> offstage_core.RouteSpec,
) -> offstage_core.RouteSpec