admin: able to download files through /files/ route
This commit is contained in:
parent
e2fdce10ef
commit
69979ced1d
2 changed files with 8 additions and 2 deletions
|
|
@ -3,8 +3,10 @@ package main
|
|||
import (
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"srs.epita.fr/fic-server/admin/api"
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
||||
"github.com/julienschmidt/httprouter"
|
||||
)
|
||||
|
|
@ -22,7 +24,7 @@ func init() {
|
|||
api.Router().GET("/events/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
||||
})
|
||||
api.Router().GET("/files/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
api.Router().GET("/files", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
||||
})
|
||||
api.Router().GET("/public/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
|
|
@ -57,6 +59,10 @@ func init() {
|
|||
http.ServeFile(w, r, path.Join(StaticDir, r.URL.Path))
|
||||
})
|
||||
|
||||
api.Router().GET("/files/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
http.ServeFile(w, r, path.Join(fic.FilesDir, strings.TrimPrefix(r.URL.Path, "/files")))
|
||||
})
|
||||
|
||||
api.Router().GET("/check_import.html", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
||||
http.ServeFile(w, r, path.Join(StaticDir, "check_import.html"))
|
||||
})
|
||||
|
|
|
|||
Reference in a new issue