You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
878 B

package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/logger"
"github.com/kataras/iris/middleware/recover"
"github.com/kataras/iris/mvc"
)
func main() {
app := iris.New()
app.Use(recover.New())
app.Use(logger.New())
mvc.New(app).Handle(new(ExampleController))
// http://localhost:8080
// http://localhost:8080/ping
// http://localhost:8080/hello
app.Run(iris.Addr(":8080"))
}
type ExampleController struct{}
func (c *ExampleController) Get() mvc.Result {
return mvc.Response{
ContentType: "text/html",
Text: "<h1>Welcome</h1>",
}
}
func (c *ExampleController) GetPing() string {
return "Pong"
}
func (c *ExampleController) GetHello() interface{} {
return map[string]string{"massage": "hello Iris!"}
}
func (c *ExampleController) GetHellos() interface{} {
return map[string]string{"massage": "hellos Iris!"}
}