mirror of
https://github.com/kataras/iris.git
synced 2026-01-04 02:37:14 +00:00
apps.Switch(apps.Hosts...) example
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/kataras/iris/v12"
|
||||
"github.com/kataras/iris/v12/context"
|
||||
@@ -53,6 +54,18 @@ func (hosts Hosts) GetSwitchCases() []SwitchCase {
|
||||
return cases
|
||||
}
|
||||
|
||||
// GetFriendlyName implements the FriendlyNameProvider.
|
||||
func (hosts Hosts) GetFriendlyName() string {
|
||||
var patterns []string
|
||||
for _, host := range hosts {
|
||||
if strings.TrimSpace(host.Pattern) != "" {
|
||||
patterns = append(patterns, host.Pattern)
|
||||
}
|
||||
}
|
||||
|
||||
return strings.Join(patterns, ", ")
|
||||
}
|
||||
|
||||
func hostApp(host Host) *iris.Application {
|
||||
if host.Target == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user