ActivityPub/utils/router/router.go

28 lines
470 B
Go
Raw Permalink Normal View History

2020-10-17 10:13:15 +00:00
package router
import (
"net/http"
"git.nutfactory.org/hoernschen/ActivityPub/utils"
"github.com/gorilla/mux"
)
func NewRouter(routes Routes) *mux.Router {
router := mux.NewRouter().StrictSlash(true)
for _, route := range routes {
var handler http.Handler
handler = route.HandlerFunc
handler = utils.APILogger(handler, route.Name)
router.
Methods(route.Method).
Path(route.Pattern).
Name(route.Name).
Handler(handler)
}
return router
}