diff --git a/internal/serv/api.go b/internal/serv/api.go index bf9ac90..aafdd36 100644 --- a/internal/serv/api.go +++ b/internal/serv/api.go @@ -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 diff --git a/internal/serv/serv.go b/internal/serv/serv.go index c00a435..5012295 100644 --- a/internal/serv/serv.go +++ b/internal/serv/serv.go @@ -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(), + "/health": http.HandlerFunc(health), + apiRoute: apiV1Handler(), } if err := setActionRoutes(routes); err != nil {