mirror of
https://github.com/safing/portbase
synced 2025-09-01 10:09:50 +00:00
29 lines
617 B
Go
29 lines
617 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/gorilla/mux"
|
|
)
|
|
|
|
var (
|
|
additionalRoutes map[string]func(arg1 http.ResponseWriter, arg2 *http.Request)
|
|
)
|
|
|
|
func RegisterAdditionalRoute(path string, handleFunc func(arg1 http.ResponseWriter, arg2 *http.Request)) {
|
|
if additionalRoutes == nil {
|
|
additionalRoutes = make(map[string]func(arg1 http.ResponseWriter, arg2 *http.Request))
|
|
}
|
|
additionalRoutes[path] = handleFunc
|
|
}
|
|
|
|
func Serve() {
|
|
|
|
router := mux.NewRouter()
|
|
router.HandleFunc("/api/database/v1", startDatabaseAPI)
|
|
|
|
for path, handleFunc := range additionalRoutes {
|
|
router.HandleFunc(path, handleFunc)
|
|
}
|
|
|
|
}
|