Skip to main content
  1. Docs/
  2. Developing Applications/

Request

Request Structure #

The handler function is passed one argument which has the details about the API call. 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
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
DatadictThe response from the handler function (passed to the template)

Accessing Inputs #

Url Parameters #

For a route defined like

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

the url parameter user_id can be accessed in the handler

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

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

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

and can be accessed as

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

Regexes are also allowed in the path, these are defined as ace.page("/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

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

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.