@@ -15,9 +15,9 @@ import (
1515// Example Code:
1616//
1717// switcher := Switch(Hosts{
18- // "mydomain.com": app,
19- // "test.mydomain.com": testSubdomainApp,
20- // "otherdomain.com": " appName",
18+ // { Pattern: "mydomain.com", Target : app } ,
19+ // { Pattern: "test.mydomain.com", Target : testSubdomainApp } ,
20+ // { Pattern: "otherdomain.com", "Target: appName" } ,
2121// })
2222// switcher.Listen(":80")
2323//
@@ -35,6 +35,28 @@ import (
3535//
3636// Wrap with the `Join` slice to pass
3737// more than one provider at the same time.
38+ //
39+ // An alternative way for manually embedding an Iris Application to another one is:
40+ //
41+ // app := iris.New() // root app.
42+ // myOtherApp := api.NewServer(otherServerConfiguration) // embedded app.
43+ // // myOtherApp.Logger().SetLevel("debug")
44+ //
45+ // if err := myOtherApp.Build(); err != nil {
46+ // panic(err)
47+ // }
48+ //
49+ // app.Any("/api/identity/{p:path}", func(ctx iris.Context) {
50+ // apiPath := "/" + ctx.Params().Get("p")
51+ // r := ctx.Request()
52+ // r.URL.Path = apiPath
53+ // r.URL.RawPath = apiPath
54+ // ctx.Params().Remove("p")
55+ //
56+ // myOtherApp.ServeHTTPC(ctx)
57+ // })
58+ //
59+ // app.Listen(":80")
3860func Switch (provider SwitchProvider , options ... SwitchOption ) * iris.Application {
3961 cases := provider .GetSwitchCases ()
4062 if len (cases ) == 0 {
0 commit comments