some changes
This commit is contained in:
32
api/router.go
Normal file
32
api/router.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
||||
"git.oblat.lv/alex/triggerssmith/internal/config"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
type Router struct {
|
||||
r chi.Router
|
||||
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
func NewRouter(cfg *config.Config) *Router {
|
||||
r := chi.NewRouter()
|
||||
return &Router{
|
||||
r: r,
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Router) RouteHandler() chi.Router {
|
||||
r.r.Get("/", func(w http.ResponseWriter, req *http.Request) {
|
||||
http.ServeFile(w, req, filepath.Join(r.cfg.Server.StaticFilesPath, "index.html"))
|
||||
})
|
||||
fs := http.FileServer(http.Dir("static"))
|
||||
r.r.Handle("/static/*", http.StripPrefix("/static/", fs))
|
||||
return r.r
|
||||
}
|
||||
Reference in New Issue
Block a user