Jobs & Workflows https://armen.surge.sh
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
1.2 KiB

/*
------------------------------------------------------------------------------------------------------------------------
####### router ####### Copyright (c) 2021 mls-361 ################################################## MIT License #######
------------------------------------------------------------------------------------------------------------------------
*/
package router
import (
"net/http"
"github.com/julienschmidt/httprouter"
"forge.chapril.org/armen/armen/internal/components"
)
type router struct {
mux *httprouter.Router
}
func newRouter() *router {
return &router{
mux: httprouter.New(),
}
}
// Build AFAIRE.
func Build(logger components.Logger) *router {
cr := newRouter()
cr.mux.PanicHandler = func(rw http.ResponseWriter, _ *http.Request, _ interface{}) {
//AFINIR: logger
rw.WriteHeader(http.StatusInternalServerError)
}
return cr
}
// Get AFAIRE.
func (cr *router) Get(path string, handler http.Handler) {
cr.mux.Handler(http.MethodGet, path, handler)
}
// Post AFAIRE.
func (cr *router) Post(path string, handler http.Handler) {
cr.mux.Handler(http.MethodPost, path, handler)
}
/*
######################################################################################################## @(°_°)@ #######
*/