portfolio/api/apiRoutes.go
2024-06-24 15:23:38 +02:00

32 lines
823 B
Go

package api
import (
"net/http"
"portfolio/api/handlers"
)
func ApiRoutes() *http.ServeMux {
// 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)
//Project
mux.HandleFunc("POST /project", handlers.CreateProjectHandler)
mux.HandleFunc("PATCH /project/{id}", handlers.UpdateProjectHandler)
mux.HandleFunc("GET /project/{id}", handlers.GetProjectHandler)
mux.HandleFunc("GET /projects", handlers.GetProjectsHandler)
return mux
}