Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bruce Flynn
chart-server
Commits
7644c33b
Commit
7644c33b
authored
Oct 03, 2018
by
Bruce Flynn
Browse files
add simple index
parent
929d5605
Changes
1
Hide whitespace changes
Inline
Side-by-side
main.go
View file @
7644c33b
...
...
@@ -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 <name> %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
)
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment