From 69979ced1d6be8d9afe0599e077867b99d70b68d Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sat, 8 Dec 2018 21:00:00 +0100 Subject: [PATCH] admin: able to download files through /files/ route --- admin/static.go | 8 +++++++- admin/static/views/exercice.html | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/admin/static.go b/admin/static.go index 3362d45e..ab65e2b1 100644 --- a/admin/static.go +++ b/admin/static.go @@ -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")) }) diff --git a/admin/static/views/exercice.html b/admin/static/views/exercice.html index 2717539f..53c132c2 100644 --- a/admin/static/views/exercice.html +++ b/admin/static/views/exercice.html @@ -44,7 +44,7 @@
- +