38 lines
1.9 KiB
Go
38 lines
1.9 KiB
Go
|
|
package app
|
||
|
|
|
||
|
|
import (
|
||
|
|
"net/http"
|
||
|
|
"path/filepath"
|
||
|
|
)
|
||
|
|
|
||
|
|
func (s *Server) Routes() http.Handler {
|
||
|
|
mux := http.NewServeMux()
|
||
|
|
mux.Handle("GET /static/", http.StripPrefix("/static/", http.FileServer(http.Dir(filepath.Join(assetRoot(), "static")))))
|
||
|
|
mux.Handle("GET /uploads/", http.StripPrefix("/uploads/", http.FileServer(http.Dir(s.cfg.UploadDir))))
|
||
|
|
|
||
|
|
mux.HandleFunc("GET /", s.home)
|
||
|
|
mux.HandleFunc("GET /projects", s.projects)
|
||
|
|
mux.HandleFunc("GET /projects/{slug}", s.projectDetail)
|
||
|
|
mux.HandleFunc("GET /projects/{slug}/images/{imageID}/overlay", s.projectImageOverlay)
|
||
|
|
mux.HandleFunc("GET /about", s.about)
|
||
|
|
mux.HandleFunc("POST /contact", s.contact)
|
||
|
|
|
||
|
|
mux.HandleFunc("GET /admin/login", s.adminLogin)
|
||
|
|
mux.HandleFunc("POST /admin/login", s.adminLoginPost)
|
||
|
|
mux.HandleFunc("POST /admin/logout", s.adminLogout)
|
||
|
|
|
||
|
|
mux.Handle("GET /admin", s.requireAdmin(http.HandlerFunc(s.adminRedirect)))
|
||
|
|
mux.Handle("GET /admin/main", s.requireAdmin(http.HandlerFunc(s.adminMain)))
|
||
|
|
mux.Handle("GET /admin/projects", s.requireAdmin(http.HandlerFunc(s.adminProjects)))
|
||
|
|
mux.Handle("GET /admin/contact-details", s.requireAdmin(http.HandlerFunc(s.adminContactDetails)))
|
||
|
|
mux.Handle("POST /admin/content", s.requireAdmin(http.HandlerFunc(s.adminUpdateContent)))
|
||
|
|
mux.Handle("POST /admin/contact-details", s.requireAdmin(http.HandlerFunc(s.adminUpdateContactDetails)))
|
||
|
|
mux.Handle("POST /admin/projects", s.requireAdmin(http.HandlerFunc(s.adminCreateProject)))
|
||
|
|
mux.Handle("POST /admin/projects/{id}", s.requireAdmin(http.HandlerFunc(s.adminUpdateProject)))
|
||
|
|
mux.Handle("POST /admin/projects/{id}/delete", s.requireAdmin(http.HandlerFunc(s.adminDeleteProject)))
|
||
|
|
mux.Handle("POST /admin/projects/{id}/images", s.requireAdmin(http.HandlerFunc(s.adminAddProjectImage)))
|
||
|
|
mux.Handle("POST /admin/project-images/{id}/delete", s.requireAdmin(http.HandlerFunc(s.adminDeleteProjectImage)))
|
||
|
|
|
||
|
|
return securityHeaders(mux)
|
||
|
|
}
|