snowuly / kob-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

kob-go

  • add Router
var app kob.App

app.Get(
	"/name/:name",
	func(ctx context.Context, w http.ResponseWriter, r *http.Request, next kob.NextFunc) {
		start := time.Now()
		next(ctx)
		w.Write([]byte(fmt.Sprintf("\nprocess cost: %d ns", time.Since(start))))
	},
	func(ctx context.Context, w http.ResponseWriter, r *http.Request, next kob.NextFunc) {
		params := kob.GetParams(ctx)
		w.Write([]byte("hello "))
		w.Write([]byte(params["name"]))
	},
)

app.Listen(":8080")

About


Languages

Language:Go 100.0%