2024-01-11 20:07:47 -08:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
|
2024-01-12 15:48:31 -08:00
|
|
|
"context"
|
|
|
|
|
2024-01-11 20:07:47 -08:00
|
|
|
"github.com/go-chi/chi/v5"
|
2024-01-12 15:48:31 -08:00
|
|
|
"github.com/rs/zerolog"
|
|
|
|
"github.com/rs/zerolog/log"
|
2024-01-11 20:07:47 -08:00
|
|
|
)
|
|
|
|
|
2024-01-12 15:48:31 -08:00
|
|
|
func SetLogLevel(level zerolog.Level) {
|
|
|
|
zerolog.SetGlobalLevel(level)
|
|
|
|
}
|
|
|
|
|
2024-01-11 20:07:47 -08:00
|
|
|
func WebRouter() http.Handler {
|
|
|
|
r := chi.NewRouter()
|
|
|
|
r.Get("/", getIndex)
|
|
|
|
return r
|
|
|
|
}
|
|
|
|
|
|
|
|
func getIndex(w http.ResponseWriter, req *http.Request) {
|
2024-01-12 15:48:31 -08:00
|
|
|
log.Debug().Msg("Got index")
|
|
|
|
component := hello("Nick")
|
|
|
|
component.Render(context.Background(), w)
|
2024-01-11 20:07:47 -08:00
|
|
|
}
|