Merge branch 'routing-capabilities' into route-loadbalancing
This commit is contained in:
@@ -118,7 +118,7 @@ func initConfig(configFile string) {
|
|||||||
configFile = GetConfigPaths()
|
configFile = GetConfigPaths()
|
||||||
}
|
}
|
||||||
conf := &GatewayConfig{
|
conf := &GatewayConfig{
|
||||||
Version: util.Version,
|
Version: util.ConfigVersion,
|
||||||
GatewayConfig: Gateway{
|
GatewayConfig: Gateway{
|
||||||
WriteTimeout: 15,
|
WriteTimeout: 15,
|
||||||
ReadTimeout: 15,
|
ReadTimeout: 15,
|
||||||
@@ -165,7 +165,7 @@ func initConfig(configFile string) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "Hostname example",
|
Name: "Hostname example",
|
||||||
Host: "http://example.localhost",
|
Hosts: []string{"example.com", "example.localhost"},
|
||||||
Path: "/",
|
Path: "/",
|
||||||
Destination: "https://example.com",
|
Destination: "https://example.com",
|
||||||
Rewrite: "/",
|
Rewrite: "/",
|
||||||
|
|||||||
@@ -202,14 +202,16 @@ func (gatewayServer GatewayServer) Initialize() *mux.Router {
|
|||||||
router := r.PathPrefix(route.Path).Subrouter()
|
router := r.PathPrefix(route.Path).Subrouter()
|
||||||
// Apply route Cors
|
// Apply route Cors
|
||||||
router.Use(CORSHandler(route.Cors))
|
router.Use(CORSHandler(route.Cors))
|
||||||
if route.Host != "" {
|
if len(route.Hosts) > 0 {
|
||||||
router.Host(route.Host).PathPrefix("").Handler(proxyRoute.ProxyHandler())
|
for _, host := range route.Hosts {
|
||||||
|
router.Host(host).PathPrefix("").Handler(proxyRoute.ProxyHandler())
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
router.PathPrefix("").Handler(proxyRoute.ProxyHandler())
|
router.PathPrefix("").Handler(proxyRoute.ProxyHandler())
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
logger.Error("Error, path is empty in route %s", route.Name)
|
logger.Error("Error, path is empty in route %s", route.Name)
|
||||||
logger.Debug("Route path ignored: %s", route.Path)
|
logger.Error("Route path ignored: %s", route.Path)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Apply global Cors middlewares
|
// Apply global Cors middlewares
|
||||||
|
|||||||
@@ -131,12 +131,14 @@ type MiddlewareName struct {
|
|||||||
|
|
||||||
// Route defines gateway route
|
// Route defines gateway route
|
||||||
type Route struct {
|
type Route struct {
|
||||||
|
// Path defines route path
|
||||||
|
Path string `yaml:"path"`
|
||||||
// Name defines route name
|
// Name defines route name
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
//Host Domain/host based request routing
|
//Host Domain/host based request routing
|
||||||
Host string `yaml:"host"`
|
//Host string `yaml:"host"`
|
||||||
// Path defines route path
|
//Hosts Domains/hosts based request routing
|
||||||
Path string `yaml:"path"`
|
Hosts []string `yaml:"hosts"`
|
||||||
// Rewrite rewrites route path to desired path
|
// Rewrite rewrites route path to desired path
|
||||||
//
|
//
|
||||||
// E.g. /cart to / => It will rewrite /cart path to /
|
// E.g. /cart to / => It will rewrite /cart path to /
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import (
|
|||||||
|
|
||||||
var Version string
|
var Version string
|
||||||
|
|
||||||
|
const ConfigVersion = "1.0"
|
||||||
|
|
||||||
func VERSION(def string) string {
|
func VERSION(def string) string {
|
||||||
build := os.Getenv("VERSION")
|
build := os.Getenv("VERSION")
|
||||||
if build == "" {
|
if build == "" {
|
||||||
|
|||||||
Reference in New Issue
Block a user