From c0ee95234da72363d9c502b2a64ab57474974f99 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 23 Jul 2020 08:57:49 +0200 Subject: [PATCH] =?UTF-8?q?Prise=20en=20compte=20des=20routes=20g=C3=A9r?= =?UTF-8?q?=C3=A9es=20par=20le=20client=20c=C3=B4t=C3=A9=20serveur?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/route/mount.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/route/mount.go b/internal/route/mount.go index af4d08b..650cf06 100644 --- a/internal/route/mount.go +++ b/internal/route/mount.go @@ -2,6 +2,7 @@ package route import ( "net/http" + "path" "time" "forge.cadoles.com/Cadoles/daddy/internal/config" @@ -62,6 +63,17 @@ func Mount(r *chi.Mux, config *config.Config) error { r.Handle("/v1/graphql", gql) }) + clientIndex := path.Join(config.HTTP.PublicDir, "index.html") + + serveClientIndex := func(w http.ResponseWriter, r *http.Request) { + http.ServeFile(w, r, clientIndex) + } + + // List of paths handled directly by the client + r.Get("/workgroups/*", serveClientIndex) + r.Get("/profile", serveClientIndex) + + // Serve static files notFoundHandler := r.NotFoundHandler() r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))