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
3 changed files with 11 additions and 0 deletions
Showing only changes of commit d998b8099f - Show all commits

View File

@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
All releases can be found on https://code.vikunja.io/api/releases.
## [Unreleased]
* Add static file support for simplified deployment
## [0.18.1] - 2021-09-08
### Fixed

View File

@ -47,6 +47,7 @@ const (
ServiceFrontendurl Key = `service.frontendurl`
ServiceEnableCaldav Key = `service.enablecaldav`
ServiceRootpath Key = `service.rootpath`
ServiceStaticpath Key = `service.staticpath`
ServiceMaxItemsPerPage Key = `service.maxitemsperpage`
// Deprecated: Use metrics.enabled
ServiceEnableMetrics Key = `service.enablemetrics`
@ -274,6 +275,7 @@ func InitDefaultConfig() {
ServiceEnableCaldav.setDefault(true)
ServiceRootpath.setDefault(getBinaryDirLocation())
ServiceStaticpath.setDefault("")
ServiceMaxItemsPerPage.setDefault(50)
ServiceEnableMetrics.setDefault(false)
ServiceMotd.setDefault("")

View File

@ -203,6 +203,11 @@ func RegisterRoutes(e *echo.Echo) {
// healthcheck
e.GET("/health", HealthcheckHandler)
// static files
if static := config.ServiceStaticpath.GetString(); static != "" {
e.Use(middleware.Static(static))
}
// CORS_SHIT
if config.CorsEnable.GetBool() {
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{