Add configuration files and update project documentation
- Introduced .editorconfig for consistent coding styles across the project. - Added .golangci.yml for Go linting configuration. - Updated AGENTS.md to clarify project structure and components. - Enhanced CONTRIBUTING.md with Makefile usage for common tasks. - Updated Dockerfiles to use Go 1.24 and improved build instructions. - Refined README.md and deployment documentation for clarity. - Added testing documentation in testing.md for backend and frontend tests. - Introduced Makefile for streamlined development commands and tasks.
This commit is contained in:
@@ -9,29 +9,27 @@ import (
|
||||
// APIHandler is the interface for API routing (implemented by handlers.Handlers).
|
||||
type APIHandler interface {
|
||||
APIRouter(rw http.ResponseWriter, req *http.Request)
|
||||
ClientRouter(rw http.ResponseWriter, req *http.Request)
|
||||
RedirectLogout(rw http.ResponseWriter, req *http.Request)
|
||||
WatchGridUpdates(rw http.ResponseWriter, req *http.Request)
|
||||
GridTile(rw http.ResponseWriter, req *http.Request)
|
||||
}
|
||||
|
||||
// Router returns the HTTP router for the app.
|
||||
// publicDir is used for /js/ static file serving (e.g. "public").
|
||||
// apiHandler handles /map/api/* requests; if nil, uses built-in apiRouter.
|
||||
func (a *App) Router(publicDir string, apiHandler APIHandler) http.Handler {
|
||||
func (a *App) Router(publicDir string, h APIHandler) http.Handler {
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Handle("/js/*", http.FileServer(http.Dir(publicDir)))
|
||||
r.HandleFunc("/client/*", a.client)
|
||||
r.HandleFunc("/logout", a.redirectLogout)
|
||||
r.HandleFunc("/client/*", h.ClientRouter)
|
||||
r.HandleFunc("/logout", h.RedirectLogout)
|
||||
|
||||
r.Route("/map", func(r chi.Router) {
|
||||
if apiHandler != nil {
|
||||
r.HandleFunc("/api/*", apiHandler.APIRouter)
|
||||
} else {
|
||||
r.HandleFunc("/api/*", a.apiRouter)
|
||||
}
|
||||
r.HandleFunc("/updates", a.watchGridUpdates)
|
||||
r.Handle("/grids/*", http.StripPrefix("/map/grids", http.HandlerFunc(a.gridTile)))
|
||||
r.HandleFunc("/api/*", h.APIRouter)
|
||||
r.HandleFunc("/updates", h.WatchGridUpdates)
|
||||
r.Handle("/grids/*", http.StripPrefix("/map/grids", http.HandlerFunc(h.GridTile)))
|
||||
})
|
||||
|
||||
r.HandleFunc("/*", a.serveSPARoot)
|
||||
r.HandleFunc("/*", a.ServeSPARoot)
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user