Skip to content

Commit

Permalink
Add chart URL tool
Browse files Browse the repository at this point in the history
  • Loading branch information
krystiancha authored and ddevault committed Dec 15, 2021
1 parent e07b344 commit c543333
Show file tree
Hide file tree
Showing 3 changed files with 804 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"net/url"
"os"
"path/filepath"
"sort"
"strconv"
"strings"
Expand Down Expand Up @@ -300,6 +301,17 @@ func main() {
registerExtension(router, "svg", "image/svg+xml")
registerExtension(router, "png", "image/png")

staticDir := os.Getenv("CHARTSRV_STATICDIR")
if staticDir == "" {
staticDir = "static"
}

router.Get("/*", func(w http.ResponseWriter, r *http.Request) {
workDir, _ := os.Getwd()
fs := http.FileServer(http.Dir(filepath.Join(workDir, staticDir)))
fs.ServeHTTP(w, r)
})

addr := ":8142"
if len(os.Args) > 2 {
addr = os.Args[2]
Expand Down
Loading

0 comments on commit c543333

Please sign in to comment.