some changes

This commit is contained in:
2025-11-30 12:50:38 +02:00
parent 004bb7ef7f
commit c1e5fc90ee
9 changed files with 140 additions and 27 deletions

32
api/router.go Normal file
View 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
}