Skip to content
📌 OpenRun now enables easy app deployments to Kubernetes. Learn more.

Request

Request Structure

The handler function is passed one argument which has the details about the API call. After the handler returns, the same request structure is passed to the template as the template context, with Data set to the handler response. The fields in this structure are:

PropertyTypeNotes
AppNamestringThe app name in the config
AppPathstringThe path where the app is installed. If root, then empty string
AppUrlstringThe url for the app root
PagePathstringThe path for the current page. If root, then empty string
PageUrlstringThe url for the current page
MethodstringThe HTTP method, GET/POST etc
IsDevboolIs the app installed in dev mode
IsPartialboolIs this an HTMX driven partial request
PushEventsboolWhether push events are enabled for this app
HtmxVersionstringThe HTMX version configured for the app
HeadersdictThe incoming HTTP headers
RemoteIPstringThe Client IP address
UrlParamsdictThe url parameters, if used in the url spec
FormdictThe form data, including body and query
QuerydictThe url query data, as a string array
PostFormdictThe form data from the body
UserIdstringThe current user id for the request
CustomPermsstring[]The custom permissions available to the user
AppRBACEnabledboolWhether app RBAC is enabled for the request
DatadictThe response from the handler function (passed to the template)

Accessing Inputs

Url Parameters

For a route defined like

app.star
ace.html("/user/{user_id}/settings", "index.go.html")

the url parameter user_id can be accessed in the handler

app.star
def handler(req)
    user_id = req.UrlParams["user_id"]

Wildcard parameters are allowed at the end of the route. These are defined as

app.star
ace.html("/path/*", "index.go.html")

and can be accessed as

app.star
def handler(req)
    user_id = req.UrlParams["*"]

Regexes are also allowed in the path, these are defined as ace.html("/articles/{aid:^[0-9]{5,6}}") and accessed as req.UrlParams["{aid}"]. The route will match only if the regex matches.

Query String Parameters

Query string parameters can be accessed as

app.star
def handler(req)
    name = req.Query.get("name")
    name = name[0] if name else None

The value for Query is an string array, since there can be multiple query parameters with the same name.

Form Data

Form data can be accessed like

app.star
def handler(req)
    name = req.Form.get("name")
    name = name[0] if name else None

The value for Form is an string array, since there can be multiple form parameters with the same name.