Static File Server
omni_httpd dispatching can include a static file server to handle serving
static assets through
omni_vfs virtual filesystem later.
The following extensions are required:
As discussed in
omni_vfs documentation, one needs to define a mount point.
This example above returns a local filesystem-based VFS. In production, you may want to consider other filesystems.
Now, we want to update our listener handler to serve this filesystem alongside with some other endpoints:
update omni_httpd.handlers set query = (select omni_httpd.cascading_query(name, query order by priority desc nulls last) from (select * from omni_httpd.static_file_handlers('mount_point', 0) union (values ('test', $$ select omni_httpd.http_response('passed') from request where request.path = '/test'$$, 1))) routes)
The above connects
mount_point() filesystem and defines a handler for
/test (with a higher priority).