mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 11:11:03 +01:00
9f85b74fc9
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
48 lines
1.2 KiB
Go
48 lines
1.2 KiB
Go
// Package main register static subdomains, simple as parties, check ./hosts if you use windows
|
|
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris"
|
|
"github.com/kataras/iris/context"
|
|
)
|
|
|
|
func main() {
|
|
app := iris.New()
|
|
|
|
// subdomains works with all available routers, like other features too.
|
|
|
|
// no order, you can register subdomains at the end also.
|
|
admin := app.Party("admin.")
|
|
{
|
|
// admin.mydomain.com
|
|
admin.Get("/", func(c context.Context) {
|
|
c.Writef("INDEX FROM admin.mydomain.com")
|
|
})
|
|
// admin.mydomain.com/hey
|
|
admin.Get("/hey", func(c context.Context) {
|
|
c.Writef("HEY FROM admin.mydomain.com/hey")
|
|
})
|
|
// admin.mydomain.com/hey2
|
|
admin.Get("/hey2", func(c context.Context) {
|
|
c.Writef("HEY SECOND FROM admin.mydomain.com/hey")
|
|
})
|
|
}
|
|
|
|
// mydomain.com/
|
|
app.Get("/", func(c context.Context) {
|
|
c.Writef("INDEX FROM no-subdomain hey")
|
|
})
|
|
|
|
// mydomain.com/hey
|
|
app.Get("/hey", func(c context.Context) {
|
|
c.Writef("HEY FROM no-subdomain hey")
|
|
})
|
|
|
|
// http://admin.mydomain.com
|
|
// http://admin.mydomain.com/hey
|
|
// http://admin.mydomain.com/hey2
|
|
// http://mydomain.com
|
|
// http://mydomain.com/hey
|
|
app.Run(iris.Addr("mydomain.com:80")) // for beginners: look ../hosts file
|
|
}
|