Skip to content

Commit

Permalink
chore: add staticServeDir flag for configurable static asset handling (
Browse files Browse the repository at this point in the history
  • Loading branch information
jdockerty authored Jul 17, 2023
1 parent 1919470 commit 1956530
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cmd/contributord/contributord.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,20 @@ import (
)

var (
cacheSize int
port string
addr string
ui bool
uiServeDir string
cacheSize int
port string
addr string
ui bool
uiServeDir string
staticServeDir string
)

func main() {
flag.IntVar(&cacheSize, "cache-size", 1000, "number of items available to cache")
flag.StringVar(&addr, "address", "localhost", "address to bind")
flag.StringVar(&port, "port", "6000", "port to bind")
flag.StringVar(&uiServeDir, "serve-dir", "templates/*", "path to templated HTML to serve as the frontend")
flag.StringVar(&staticServeDir, "static-assets-dir", "static", "path where static assets are served from for the frontend")
flag.Parse()

githubToken := os.Getenv("GH_TOKEN_CONTRIBUTED_TO")
Expand Down Expand Up @@ -59,9 +61,10 @@ func main() {

if uiServeDir != "" {
log.Printf("Serving templated UI from %s\n", uiServeDir)
log.Printf("Serving static assets from %s\n", staticServeDir)

router.LoadHTMLGlob(uiServeDir) // Load templated HTML into renderer
router.Static("./static", "static")
router.Static("/static", staticServeDir)

// Initial loading of the page, no value is given
router.GET("/", func(c *gin.Context) {
Expand Down

0 comments on commit 1956530

Please sign in to comment.