1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-21 11:57:02 +00:00

Nothing special here, just split the static handler to a package-level func and per-route func (same as before)

Former-commit-id: 1912d85de84856c715dfa7b79d771cada1b638b9
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-03-14 02:58:56 +02:00
parent f487cd0029
commit ac3abca684
5 changed files with 130 additions and 87 deletions

View File

@@ -23,6 +23,18 @@ func main() {
// Serve static files (css)
app.StaticWeb("/static", "./static_files")
// other solution for both static files and urls in the root path(not recommended but it's here if you ever need it):
// fileserver := iris.StaticHandler("./static_files", false, false)
// app.Get("/*path", func(ctx *iris.Context) {
// fileserver.Serve(ctx)
// if ctx.StatusCode() >= 200 && ctx.StatusCode() < 300 {
// // then the file found and served correctly.
// } else {
// // otherwise check for urls....
// execShortURL(ctx, ctx.Param("path"))
// }
// })
var mu sync.Mutex
var urls = map[string]string{
"iris": "http://support.iris-go.com",
@@ -53,7 +65,7 @@ func main() {
execShortURL(ctx, ctx.Param("shortkey"))
})
// for wildcard subdomain (yeah.. cool) http://dsaoj41u321dsa.localhost:8080
// for wildcard subdomain (yeah.. cool) http://dsaoj41u321dsa.localhost:8080
// Note:
// if you want subdomains (chrome doesn't works on localhost, so you have to define other hostname on app.Listen)
// app.Party("*.", func(ctx *iris.Context) {