add file, not tested

This commit is contained in:
codeskyblue
2016-07-22 20:20:17 +08:00
parent 9f9c3acbb5
commit 88d3d960ae

15
main.go
View File

@@ -1,8 +1,11 @@
package main
import (
"strings"
"github.com/alecthomas/kingpin"
"github.com/kataras/iris"
"github.com/kataras/iris/utils"
)
type Configure struct {
@@ -23,5 +26,17 @@ func main() {
iris.Get("/hi", func(ctx *iris.Context) {
ctx.Write("Hi %s", "iris")
})
iris.Get("/*file", func(ctx *iris.Context) {
requestPath := ctx.Param("file")
path := strings.Replace(requestPath, "/", utils.PathSeparator, -1)
if !utils.DirectoryExists(path) {
ctx.NotFound()
return
}
ctx.ServeFile(path, false)
})
iris.Listen(gcfg.Addr)
}