You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
1008 B
Go
30 lines
1008 B
Go
package server
|
|
|
|
import (
|
|
"database/sql"
|
|
"log/slog"
|
|
"net/http"
|
|
|
|
"git.runcible.io/learning/ratchet/internal/model"
|
|
)
|
|
|
|
func addRoutes(mux *http.ServeMux,
|
|
logger *slog.Logger,
|
|
tc *TemplateCache,
|
|
db *sql.DB,
|
|
snippetService *model.SnippetService) http.Handler {
|
|
|
|
// /{$} is used to prevent subtree path patterns from acting like a wildcard
|
|
// resulting in this route requiring an exact match on "/" only
|
|
// You can only include one HTTP method in a route pattern if you choose
|
|
// GET will match GET & HEAD http request methods
|
|
mux.Handle("GET /{$}", handleHome(logger, tc, snippetService))
|
|
mux.Handle("GET /snippet/view/{id}", handleSnippetView(logger, tc, snippetService))
|
|
mux.Handle("GET /snippet/create", handleSnippetCreateGet())
|
|
mux.Handle("POST /snippet/create", handleSnippetCreatePost(logger, tc, snippetService))
|
|
// mux.Handle("/something", handleSomething(logger, config))
|
|
// mux.Handle("/healthz", handleHealthzPlease(logger))
|
|
// mux.Handle("/", http.NotFoundHandler())
|
|
return mux
|
|
}
|