2016-01-13 00:22:01 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
2016-01-22 16:34:34 +00:00
|
|
|
"path"
|
2018-12-08 20:00:00 +00:00
|
|
|
"strings"
|
2016-01-13 00:22:01 +00:00
|
|
|
|
2016-12-15 23:51:56 +00:00
|
|
|
"srs.epita.fr/fic-server/admin/api"
|
2019-01-19 00:02:10 +00:00
|
|
|
"srs.epita.fr/fic-server/admin/sync"
|
2018-12-08 20:00:00 +00:00
|
|
|
"srs.epita.fr/fic-server/libfic"
|
2016-01-22 16:34:34 +00:00
|
|
|
|
2016-12-15 23:51:56 +00:00
|
|
|
"github.com/julienschmidt/httprouter"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
api.Router().GET("/", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2018-01-17 00:21:32 +00:00
|
|
|
api.Router().GET("/claims/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2016-12-15 23:51:56 +00:00
|
|
|
api.Router().GET("/exercices/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
|
|
|
api.Router().GET("/events/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2018-12-08 20:00:00 +00:00
|
|
|
api.Router().GET("/files", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
2017-12-27 00:53:01 +00:00
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2017-12-17 23:30:23 +00:00
|
|
|
api.Router().GET("/public/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
2017-01-20 18:18:43 +00:00
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2018-01-21 13:18:26 +00:00
|
|
|
api.Router().GET("/pki/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2017-01-15 01:37:59 +00:00
|
|
|
api.Router().GET("/settings/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2016-12-15 23:51:56 +00:00
|
|
|
api.Router().GET("/teams/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
|
|
|
api.Router().GET("/themes/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "index.html"))
|
|
|
|
})
|
2016-01-22 16:34:34 +00:00
|
|
|
|
2016-12-15 23:51:56 +00:00
|
|
|
api.Router().GET("/css/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, r.URL.Path))
|
|
|
|
})
|
|
|
|
api.Router().GET("/fonts/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, r.URL.Path))
|
|
|
|
})
|
|
|
|
api.Router().GET("/img/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, r.URL.Path))
|
|
|
|
})
|
|
|
|
api.Router().GET("/js/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, r.URL.Path))
|
|
|
|
})
|
|
|
|
api.Router().GET("/views/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, r.URL.Path))
|
|
|
|
})
|
2017-12-12 06:11:56 +00:00
|
|
|
|
2018-12-08 20:00:00 +00:00
|
|
|
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")))
|
|
|
|
})
|
2019-01-19 00:02:10 +00:00
|
|
|
api.Router().GET("/vids/*_", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
if importer, ok := sync.GlobalImporter.(sync.LocalImporter); ok {
|
|
|
|
http.ServeFile(w, r, path.Join(importer.Base, strings.TrimPrefix(r.URL.Path, "/vids")))
|
|
|
|
} else {
|
|
|
|
http.Error(w, "Only available with local importer.", 400)
|
|
|
|
}
|
|
|
|
})
|
2018-12-08 20:00:00 +00:00
|
|
|
|
2017-12-12 06:11:56 +00:00
|
|
|
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"))
|
|
|
|
})
|
|
|
|
api.Router().GET("/full_import_report.json", func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
|
|
|
|
http.ServeFile(w, r, path.Join(StaticDir, "full_import_report.json"))
|
|
|
|
})
|
2016-01-13 00:22:01 +00:00
|
|
|
}
|