1 Star 0 Fork 0

sonysoul/iris

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
.github
_benchmarks
_examples
apidoc/yaag
authentication
cache
configuration
convert-handlers
cookies
dependency-injection/basic
desktop-app
docker
experimental-handlers
file-server
hello-world
hero
http-listening
http_request
http_responsewriter
i18n
miscellaneous
mvc
orm
overview
routing
sessions
sitemap
structuring
subdomains
multi
redirect
single
hosts
main.go
wildcard
www
testing/httptest
tutorial
versioning
view
webassembly/basic
websocket
README.md
README_ZH.md
cache
context
core
hero
httptest
i18n
macro
middleware
mvc
sessions
typescript
versioning
view
websocket
.fossa.yml
.gitattributes
.gitignore
.travis.yml
AUTHORS
CODE_OF_CONDUCT.md
CONTRIBUTING.md
FAQ.md
HISTORY.md
HISTORY_ES.md
LICENSE
NOTICE
README.md
README_ES.md
README_FA.md
README_GR.md
README_KO.md
README_RU.md
README_ZH.md
VERSION
configuration.go
configuration_test.go
doc.go
go.mod
go19.go
iris.go
克隆/下载
main.go 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
// Package main register static subdomains, simple as parties, check ./hosts if you use windows
package main
import (
"github.com/kataras/iris/v12"
)
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 iris.Context) {
c.Writef("INDEX FROM admin.mydomain.com")
})
// admin.mydomain.com/hey
admin.Get("/hey", func(c iris.Context) {
c.Writef("HEY FROM admin.mydomain.com/hey")
})
// admin.mydomain.com/hey2
admin.Get("/hey2", func(c iris.Context) {
c.Writef("HEY SECOND FROM admin.mydomain.com/hey")
})
}
// mydomain.com/
app.Get("/", func(c iris.Context) {
c.Writef("INDEX FROM no-subdomain hey")
})
// mydomain.com/hey
app.Get("/hey", func(c iris.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.Listen("mydomain.com:80") // for beginners: look ../hosts file
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sonysoul/iris.git
git@gitee.com:sonysoul/iris.git
sonysoul
iris
iris
master

搜索帮助