feat: add config to set api endpoint prefix
This commit is contained in:
parent
bdc8c65a09
commit
505335d872
|
@ -45,6 +45,7 @@ type Serv struct {
|
|||
MigrationsPath string `mapstructure:"migrations_path"`
|
||||
AllowedOrigins []string `mapstructure:"cors_allowed_origins"`
|
||||
DebugCORS bool `mapstructure:"cors_debug"`
|
||||
APIPath string `mapstructure:"api_path"`
|
||||
|
||||
Auth auth.Auth
|
||||
Auths []auth.Auth
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"net/http"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -111,9 +112,15 @@ func routeHandler() (http.Handler, error) {
|
|||
return mux, nil
|
||||
}
|
||||
|
||||
apiRoute := "/api/v1/graphql"
|
||||
|
||||
if len(conf.APIPath) != 0 {
|
||||
apiRoute = path.Join("/", conf.APIPath, "/v1/graphql")
|
||||
}
|
||||
|
||||
routes := map[string]http.Handler{
|
||||
"/health": http.HandlerFunc(health),
|
||||
"/api/v1/graphql": apiV1Handler(),
|
||||
apiRoute: apiV1Handler(),
|
||||
}
|
||||
|
||||
if err := setActionRoutes(routes); err != nil {
|
||||
|
|
Loading…
Reference in New Issue