Ability to serve static files #1174

Merged
konrad merged 3 commits from grahammiln/api:main into main 2022-05-23 20:49:33 +00:00
Contributor

Description

Added the configuration key, service.staticpath, to serve files from the configuration path on root (/).

Serving static files allows the api service to also serve the frontend content. This is a simple option for deploying Vikunja without needing any other servers or proxies.

Running a complete instance becomes:

VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja

Where /path/to/frontend is a copy of Vikunja's frontend static files.

Implementation

Providing a path, via the configuration or environment, adds a static file middleware to serve the path's contents from root (/).

By default, the configuration path is empty and Vikunja's existing behaviour is unchanged.

Checklist

  • I added or improved tests
  • I added or improved docs for my feature
    • Swagger (including mage do-the-swag)
    • Error codes
    • New config options (including adding them to config.yml.saml and running mage generate-docs)
# Description Added the configuration key, `service.staticpath`, to serve files from the configuration path on root (/). Serving static files allows the api service to also serve the frontend content. This is a simple option for deploying Vikunja without needing any other servers or proxies. Running a complete instance becomes: VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja Where `/path/to/frontend` is a copy of Vikunja's frontend static files. ## Implementation Providing a path, via the configuration or environment, adds a static file middleware to serve the path's contents from root (/). By default, the configuration path is empty and Vikunja's existing behaviour is unchanged. # Checklist * [ ] I added or improved tests * [X] I added or improved docs for my feature * [X] Swagger (including `mage do-the-swag`) * [ ] Error codes * [X] New config options (including adding them to `config.yml.saml` and running `mage generate-docs`)
grahammiln added 3 commits 2022-05-22 15:38:31 +00:00
d998b8099f Add ability to serve static files.
Added a configuration key, `service.staticpath`, to allow the serving
of files from the provided path. By default, the path is empty and
Vikunja's existing behaviour is unchanged.

Providing a path via the configuration, adds a static file middleware to
serve the path's contents from root (/).

Being able to serve static files allows the api service to also serve
the frontend content. This adds a simple option for deploying Vikunja
without needing any other servers or proxies.

Running a complete instance becomes:

VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja

Where /path/to/frontend is a copy of Vikunja's frontend static files.

Future improvements could embed a copy of the frontend files via the
fs.FS and embed package. Alternatively a reverse proxy could be offered
using http/httputil's ReverseProxy; this would allow another server to
maintain a default set of frontend files without embedding.
continuous-integration/drone/pr Build is passing Details
b248b98914
Document static path option.
continuous-integration/drone/pr Build is passing Details
25325c28f1
Reverted.
Reverted, as requested.
Owner

No need to close and reopen another pr :)

No need to close and reopen another pr :)
konrad approved these changes 2022-05-23 20:48:48 +00:00
konrad left a comment
Owner

Thanks!

Thanks!
konrad merged commit acaa85083f into main 2022-05-23 20:49:31 +00:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: vikunja/vikunja#1174
No description provided.