Web
Simple web pages can be made, Sugoi has built-in custom template rendering engine called Origami. But you can plug in whichever template rendering engine you want, and use a custom HttpResponse object to return it from the controller.
The template root directory for pages is resources/templates/views
. But can be changed with the config property. This is the base path referred to in the Page attributes when registering pages. Return values of the controller function is automatically piped into the template renderer.
Notice how the ApiController attribute was also added here, if you wanted to (for some reason), you could in theory re-use all your controllers to render to either templates or JSON. The route discovery will always segregate controller hints by type regardless, so long as the routes themselves don't overlap this is completely valid usage.
#[WebController(path: '/')]
#[ApiController(path: '/api')]
class ExampleController
{
#[Page(path: 'home', template: 'home')]
#[RouteGet(path: 'home')]
public function index(): array
{
return [
'title' => 'Hello, World!',
'message' => 'This works well you know!',
];
}
#[PagePost(path: 'home', template: 'home-submit')]
#[RoutePost(path: 'home')]
public function index(#[BindBody] ExampleForm $form): array
{
return [
'status' => 'Success',
];
}
}
Configuration
HTTP configuration options.
sugoi:
http:
address: 0.0.0.0
port: 3000
path: /
Health Checks
Some features are automatically enabled for you out of the box for HTTP services. In particular SwaggerUI is bundled within the framework and auto-generates documentation based on the framework attributes and can be viewed from the dev tools.
Name | Path |
---|---|
Health Check | /healthz |