mirror of
https://github.com/1f349/gomvn.git
synced 2024-12-22 07:54:12 +00:00
Add support for HEAD method and parent folder link
This commit is contained in:
parent
d7b6f38f40
commit
f2a9788c49
@ -49,6 +49,9 @@ type fileInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *routeCtx) handleDirList(rw http.ResponseWriter, req *http.Request) {
|
func (r *routeCtx) handleDirList(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
if req.Method == http.MethodHead {
|
||||||
|
return
|
||||||
|
}
|
||||||
openDir, err := os.ReadDir(filepath.Join(r.basePath, req.URL.Path))
|
openDir, err := os.ReadDir(filepath.Join(r.basePath, req.URL.Path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(rw, "404 Not Found", http.StatusNotFound)
|
http.Error(rw, "404 Not Found", http.StatusNotFound)
|
||||||
|
@ -29,6 +29,11 @@
|
|||||||
<th>Last Modified</th>
|
<th>Last Modified</th>
|
||||||
<th>Size</th>
|
<th>Size</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="bold"><a href="../">../</a></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
{{range .Files}}
|
{{range .Files}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="bold"><a href="{{ .URL }}">{{ .Name }}</a></td>
|
<td class="bold"><a href="{{ .URL }}">{{ .Name }}</a></td>
|
||||||
|
@ -59,8 +59,10 @@ func Router(db *database.Queries, name, basePath string, repository []string) ht
|
|||||||
rWeb := httprouter.New()
|
rWeb := httprouter.New()
|
||||||
rWeb.PUT("/*filepath", base.repoAuth(base.handlePut))
|
rWeb.PUT("/*filepath", base.repoAuth(base.handlePut))
|
||||||
rWeb.GET("/", base.handleFiles)
|
rWeb.GET("/", base.handleFiles)
|
||||||
|
rWeb.HEAD("/", base.handleFiles)
|
||||||
for _, repo := range repository {
|
for _, repo := range repository {
|
||||||
rWeb.GET(path.Join("/", repo, "*filepath"), base.handleFiles)
|
rWeb.GET(path.Join("/", repo, "*filepath"), base.handleFiles)
|
||||||
|
rWeb.HEAD(path.Join("/", repo, "*filepath"), base.handleFiles)
|
||||||
}
|
}
|
||||||
|
|
||||||
mux := http.NewServeMux()
|
mux := http.NewServeMux()
|
||||||
|
Loading…
Reference in New Issue
Block a user