Skip to content
Snippets Groups Projects
Commit 7644c33b authored by Bruce Flynn's avatar Bruce Flynn
Browse files

add simple index

parent 929d5605
Branches main
No related tags found
No related merge requests found
......@@ -62,7 +62,23 @@ func handleUpload(w http.ResponseWriter, r *http.Request) {
log.Printf("successfully handled chart %s", path.Base(p))
}
func handleGet(w http.ResponseWriter, r *http.Request) {
func handleGetHome(w http.ResponseWriter, r *http.Request) {
w.Write([]byte(fmt.Sprintf(`
<div>
<h1>Chart Repository</h1>
<p>
To add this repostory to Helm, run:
<code>
<pre>
helm repo add &lt;name&gt; %s
</pre>
</code>
</p>
</div>
`, url)))
}
func handleGetFile(w http.ResponseWriter, r *http.Request) {
p := path.Join(dir, r.URL.Path)
if st, err := os.Stat(p); os.IsNotExist(err) || st.IsDir() {
http.Error(w, "Not Found", http.StatusNotFound)
......@@ -86,7 +102,11 @@ func handle(w http.ResponseWriter, r *http.Request) {
case "PUT":
handleUpload(w, r)
case "GET":
handleGet(w, r)
if r.URL.Path == "/" {
handleGetHome(w, r)
} else {
handleGetFile(w, r)
}
default:
http.Error(w, "Bad Request", http.StatusBadRequest)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment