Skip to content

Commit

Permalink
refactor(go): Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
rkettelerij committed Sep 25, 2024
1 parent cbfbaf1 commit 06460e6
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions internal/engine/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ import (

// Serve static assets either from local storage or through reverse proxy
func newResourcesEndpoint(e *Engine) {
resourcesDir := ""
if e.Config.Resources.Directory != nil {
resourcesDir = *e.Config.Resources.Directory
}
resourcesURL := ""
if e.Config.Resources.URL != nil {
resourcesURL = e.Config.Resources.URL.String()
}

if resourcesDir != "" {
resourcesPath := strings.TrimSuffix(resourcesDir, "/resources")
if e.Config.Resources.Directory != nil && *e.Config.Resources.Directory != "" {
resourcesPath := strings.TrimSuffix(*e.Config.Resources.Directory, "/resources")
e.Router.Handle("/resources/*", http.FileServer(http.Dir(resourcesPath)))
} else if resourcesURL != "" {
e.Router.Get("/resources/*", proxy(e.ReverseProxy, resourcesURL))
} else if e.Config.Resources.URL != nil && e.Config.Resources.URL.String() != "" {
e.Router.Get("/resources/*", proxy(e.ReverseProxy, e.Config.Resources.URL.String()))
}
}

Expand Down

0 comments on commit 06460e6

Please sign in to comment.