github.com/goplus/yap@v0.8.1/demo/hello/hello.go (about)

     1  package main
     2  
     3  import (
     4  	"github.com/goplus/yap"
     5  )
     6  
     7  func main() {
     8  	y := yap.New()
     9  	y.GET("/", func(ctx *yap.Context) {
    10  		ctx.TEXT(200, "text/html", `<html><body>Hello, <a href="/p/123">YAP</a>!</body></html>`)
    11  	})
    12  	y.GET("/p/:id", func(ctx *yap.Context) {
    13  		ctx.JSON(200, yap.H{
    14  			"id": ctx.Param("id"),
    15  		})
    16  	})
    17  	y.Run("localhost:8080")
    18  }