Newer
Older
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/auth"
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/common"
"forge.grandlyon.com/web-et-numerique/llle_project/backoffice-server/internal/monthlyNews"
"github.com/nicolaspernoud/vestibule/pkg/middlewares"
Manager *auth.Manager
}
func CreateRootMux(staticDir string) RootMux {
r.HandleFunc("/OAuth2Login", m.HandleOAuth2Login)
r.Handle("/OAuth2Callback", m.HandleOAuth2Callback())
r.HandleFunc("/Logout", m.HandleLogout)
r.Handle("/api/common/WhoAmI", auth.ValidateAuthMiddleware(auth.WhoAmI(), []string{"*"}, false))
// Serve static files falling back to serving index.html
fs := http.StripPrefix("/public/", middlewares.NoCache(http.FileServer(&common.FallBackWrapper{Assets: http.Dir(staticDir)})))
r.PathPrefix("/public/").Handler(fs)
http.Handle("/", r)
apiAdmin := r.PathPrefix("/api/admin").Subrouter()
apiAdmin.Use(auth.AdminAuthMiddleware)
apiAdmin.HandleFunc("/monthlyNews", monthlyNews.AddMonthlyNews).Methods(http.MethodPost)
apiAdmin.HandleFunc("/monthlyNews/{year}/{month}", monthlyNews.DeleteMonthlyNews).Methods(http.MethodDelete)
apiAdmin.HandleFunc("/monthlyNews/{year}/{month}", monthlyNews.GetSingleMonthlyNews).Methods(http.MethodGet)
apiAdmin.HandleFunc("/monthlyNews", monthlyNews.GetAllMonthlyNews).Methods(http.MethodGet)
return RootMux{r, &m}