2024-05-16 18:42:31 +02:00
|
|
|
package api
|
2024-05-16 17:59:21 +02:00
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
|
2024-05-19 23:56:53 +02:00
|
|
|
// routes
|
2024-05-16 18:42:31 +02:00
|
|
|
mux.HandleFunc("/", handlers.CatchAllHandler)
|
2024-05-19 23:56:53 +02:00
|
|
|
mux.HandleFunc("GET /check", handlers.CheckRoleHandler)
|
|
|
|
|
|
|
|
|
|
//user
|
2024-05-19 17:49:20 +02:00
|
|
|
mux.HandleFunc("GET /user/{id}", handlers.GetUser)
|
2024-05-19 23:56:53 +02:00
|
|
|
|
|
|
|
|
//auth
|
2024-05-19 17:49:20 +02:00
|
|
|
mux.HandleFunc("POST /login", handlers.Login)
|
2024-05-19 23:56:53 +02:00
|
|
|
mux.HandleFunc("POST /register", handlers.CreateUser)
|
2024-05-16 17:59:21 +02:00
|
|
|
|
|
|
|
|
return mux
|
|
|
|
|
}
|