From 4b43ca5f1b5a2d718eb98596203557c3799a8d80 Mon Sep 17 00:00:00 2001 From: xushiwei Date: Sat, 6 Jan 2024 22:26:30 +0800 Subject: [PATCH] Update README.md --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 00a6a62..6646593 100644 --- a/README.md +++ b/README.md @@ -6,3 +6,22 @@ yap - Yet Another Go/Go+ HTTP Web Framework [![GitHub release](https://img.shields.io/github/v/tag/goplus/yap.svg?label=release)](https://github.com/goplus/yap/releases) [![Coverage Status](https://codecov.io/gh/goplus/yap/branch/main/graph/badge.svg)](https://codecov.io/gh/goplus/yap) [![GoDoc](https://pkg.go.dev/badge/github.com/goplus/yap.svg)](https://pkg.go.dev/github.com/goplus/yap) + +### Router and Parameters + +demo ([hello.go](demo/hello/hello.go)): + +```go +import "github.com/goplus/yap" + +y := yap.New() +y.GET("/p/:id", func(ctx *yap.Context) { + ctx.JSON(200, yap.H{ + "id": ctx.Param("id"), + }) +}) +y.Handle("/", func(ctx *yap.Context) { + ctx.TEXT(200, "text/html", `Hello, Yap!`) +}) +y.Run(":8080") +```