mirror of
https://github.com/sammyshear/trivia-chase.git
synced 2025-12-06 03:55:53 +00:00
24 lines
494 B
Go
24 lines
494 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/a-h/templ"
|
|
"github.com/sammyshear/trivia-chase/views/pages"
|
|
)
|
|
|
|
func NewRoutes() *http.ServeMux {
|
|
mux := http.NewServeMux()
|
|
|
|
// pages and static assets
|
|
indexPage := pages.Home()
|
|
mux.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static"))))
|
|
mux.Handle("/", templ.Handler(indexPage))
|
|
|
|
// api routes
|
|
mux.HandleFunc("POST /api/question", GetQuestion)
|
|
mux.HandleFunc("GET /api/session", OpenSession)
|
|
|
|
return mux
|
|
}
|