O Language/Web/Routing
From OnixOS
Routing
Routes are stored as a hash passed to webserver. A route maps a path to an HTTP method and a response.
def show_user = fn(id) {
return json({"id": id})
}
def config = {
"/users/:id": {
"type": "GET",
"response": show_user
}
}
Supported route types include GET, POST, PUT, DELETE, PATCH, OPTIONS, UPLOAD, and STATIC.
Generated routes
In a web project, olang web create route writes routes directly to config/config.ola. It does not create a separate routes file. Creating a controller also adds its route and leaves the generated function empty for the developer to implement.
