Migrer exposition statique à StaticWithConfig
Ajouter groupStatic pour StaticWithConfig Retirer handlers manuels redondants par StaticWithConfig
This commit is contained in:
parent
2eee1f2fd2
commit
6bc791506a
5 changed files with 26 additions and 22 deletions
|
@ -134,6 +134,14 @@ func RunServer() {
|
|||
|
||||
e.Pre(middleware.RemoveTrailingSlash())
|
||||
|
||||
groupStatic := e.Group("/public/*")
|
||||
groupStatic.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||
Root: "/",
|
||||
Filesystem: http.FS(publicFS),
|
||||
//TODO
|
||||
//Browse: true,
|
||||
}))
|
||||
|
||||
groupV1 := e.Group("/v1")
|
||||
|
||||
groupV1.Use(middleware.AddTrailingSlash())
|
||||
|
@ -193,12 +201,6 @@ func RunServer() {
|
|||
|
||||
groupV1.DELETE("/bucket/:bucket/:document", handleV1DocumentDelete)
|
||||
|
||||
// Static Routes
|
||||
|
||||
e.GET("/static/general.css", handleStaticCSSGeneral)
|
||||
|
||||
e.GET("/static/index.css", handleStaticCSSIndex)
|
||||
|
||||
// HTML Routes
|
||||
|
||||
e.GET("/", handleIndex)
|
||||
|
@ -745,17 +747,3 @@ func handleAdminDocumentsUploadPOST(c echo.Context) error {
|
|||
|
||||
return c.Render(http.StatusOK, "admin-upload-html", struct{ Message string }{Message: message})
|
||||
}
|
||||
|
||||
// CSS Handlers
|
||||
|
||||
func handleStaticCSSIndex(c echo.Context) error {
|
||||
// TODO Ajouter gestion d'erreurs
|
||||
data, _ := publicFS.ReadFile("css/index.css")
|
||||
return c.Blob(http.StatusOK, "text/css", data)
|
||||
}
|
||||
|
||||
func handleStaticCSSGeneral(c echo.Context) error {
|
||||
// TODO Ajouter gestion d'erreurs
|
||||
data, _ := publicFS.ReadFile("css/general.css")
|
||||
return c.Blob(http.StatusOK, "text/css", data)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue