2017-08-20 09:42:31 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12/_benchmarks/iris-mvc-templates/controllers"
|
2017-08-20 09:42:31 +02:00
|
|
|
|
2019-10-25 00:27:02 +02:00
|
|
|
"github.com/kataras/iris/v12"
|
|
|
|
"github.com/kataras/iris/v12/context"
|
|
|
|
"github.com/kataras/iris/v12/mvc"
|
2017-08-20 09:42:31 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2017-11-21 10:34:04 +01:00
|
|
|
// publicDir is the exactly the same path that .NET Core is using for its templates,
|
2017-08-20 09:42:31 +02:00
|
|
|
// in order to reduce the size in the repository.
|
|
|
|
// Change the "C\\mygopath" to your own GOPATH.
|
2017-11-21 10:34:04 +01:00
|
|
|
// publicDir = "C:\\mygopath\\src\\github.com\\kataras\\iris\\_benchmarks\\netcore-mvc-templates\\wwwroot"
|
|
|
|
publicDir = "/home/kataras/mygopath/src/github.com/kataras/iris/_benchmarks/netcore-mvc-templates/wwwroot"
|
2017-08-20 09:42:31 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
app := iris.New()
|
|
|
|
app.RegisterView(iris.HTML("./views", ".html").Layout("shared/layout.html"))
|
2019-06-21 18:43:25 +02:00
|
|
|
app.HandleDir("/public", publicDir)
|
2017-08-20 09:42:31 +02:00
|
|
|
app.OnAnyErrorCode(onError)
|
2017-12-22 09:18:31 +01:00
|
|
|
|
2017-12-27 03:15:41 +01:00
|
|
|
mvc.New(app).Handle(new(controllers.HomeController))
|
2017-12-22 09:18:31 +01:00
|
|
|
|
2018-10-21 18:20:05 +02:00
|
|
|
app.Run(iris.Addr(":5000"))
|
2017-08-20 09:42:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
type err struct {
|
|
|
|
Title string
|
|
|
|
Code int
|
|
|
|
}
|
|
|
|
|
|
|
|
func onError(ctx context.Context) {
|
|
|
|
ctx.ViewData("", err{"Error", ctx.GetStatusCode()})
|
|
|
|
ctx.View("shared/error.html")
|
|
|
|
}
|