feat: add config to set api endpoint prefix

This commit is contained in:
Vikram Rangnekar 2020-04-24 01:23:35 -04:00
parent bdc8c65a09
commit 505335d872
2 changed files with 10 additions and 2 deletions

View File

@ -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

View File

@ -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 {