1
0
mirror of https://github.com/go-kratos/kratos.git synced 2026-05-22 10:15:24 +02:00

add sub router for http

This commit is contained in:
longXboy
2021-07-18 19:30:39 +08:00
parent 5d07a94b16
commit 078ca6bc9b
4 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -9,7 +9,7 @@ import (
func sayHelloHandler(ctx http.Context) error {
var in helloworld.HelloRequest
if err := ctx.Bind(&in); err != nil {
if err := ctx.BindQuery(&in); err != nil {
return err
}
+4
View File
@@ -30,6 +30,10 @@ func main() {
// add path filter to custom route
r.GET("/hello/{name}", sayHelloHandler, pathFilter, pathFilter2)
// add path filter to sub router
r2 := r.NewSubRouter("/v2", pathFilter, pathFilter2)
r2.GET("/say/{name}", sayHelloHandler)
app := kratos.New(
kratos.Name("helloworld"),
kratos.Server(