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"`
|
MigrationsPath string `mapstructure:"migrations_path"`
|
||||||
AllowedOrigins []string `mapstructure:"cors_allowed_origins"`
|
AllowedOrigins []string `mapstructure:"cors_allowed_origins"`
|
||||||
DebugCORS bool `mapstructure:"cors_debug"`
|
DebugCORS bool `mapstructure:"cors_debug"`
|
||||||
|
APIPath string `mapstructure:"api_path"`
|
||||||
|
|
||||||
Auth auth.Auth
|
Auth auth.Auth
|
||||||
Auths []auth.Auth
|
Auths []auth.Auth
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -111,9 +112,15 @@ func routeHandler() (http.Handler, error) {
|
||||||
return mux, nil
|
return mux, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apiRoute := "/api/v1/graphql"
|
||||||
|
|
||||||
|
if len(conf.APIPath) != 0 {
|
||||||
|
apiRoute = path.Join("/", conf.APIPath, "/v1/graphql")
|
||||||
|
}
|
||||||
|
|
||||||
routes := map[string]http.Handler{
|
routes := map[string]http.Handler{
|
||||||
"/health": http.HandlerFunc(health),
|
"/health": http.HandlerFunc(health),
|
||||||
"/api/v1/graphql": apiV1Handler(),
|
apiRoute: apiV1Handler(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := setActionRoutes(routes); err != nil {
|
if err := setActionRoutes(routes); err != nil {
|
||||||
|
|
Loading…
Reference in New Issue