portfolio/api/apiRoutes.go
Darius klein 5e1cd15c07
All checks were successful
build and deploy portfolio / build (pull_request) Successful in 51s
build and deploy portfolio / publish-docs (pull_request) Successful in 4s
build and deploy portfolio / publish-portfolio (pull_request) Successful in 3s
Version bump + migration dependencies
2025-05-07 22:33:21 +02:00

37 lines
1.0 KiB
Go

package api
import (
"log"
"net/http"
"portfolio/api/handlers"
)
func Routes() *http.ServeMux {
log.Println("Setup web routes")
// Create a new request multiplexer
// Take incoming requests and dispatch them to the matching webHandler
mux := http.NewServeMux()
// routes
mux.HandleFunc("/", handlers.CatchAllHandler)
mux.HandleFunc("GET /check", handlers.CheckRoleHandler)
//user
mux.HandleFunc("GET /user/{id}", handlers.GetUserHandler)
//auth
mux.HandleFunc("POST /login", handlers.Login)
mux.HandleFunc("POST /register", handlers.CreateUserHandler)
mux.HandleFunc("GET /htmx/canEdit", handlers.CanEdit)
//Project
mux.HandleFunc("POST /project", handlers.CreateProjectHandler)
mux.HandleFunc("PATCH /project/{id}", handlers.UpdateProjectHandler)
mux.HandleFunc("PATCH /projects", handlers.UpdateProjectsHandler)
mux.HandleFunc("GET /project/{id}", handlers.GetProjectHandler)
mux.HandleFunc("GET /projects", handlers.GetProjectsHandler)
mux.HandleFunc("GET /projects/backup", handlers.GetProjectsBackupHandler)
return mux
}