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.
 
 

38 lines
779 B

package main
import (
"context"
"flag"
"fmt"
"git.diulo.com/mogfee/kit"
"git.diulo.com/mogfee/kit/middleware"
"git.diulo.com/mogfee/kit/transport/http"
"github.com/gin-gonic/gin"
)
func main() {
flag.Parse()
runApp("localhost:8998")
}
func runApp(host string) {
hs := http.NewServer(
http.Address(host),
http.Middleware(func(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, a any) (any, error) {
fmt.Println("middleware")
return handler(ctx, a)
}
}),
)
r := hs.Route("")
r.GET("/api/v2/user/me", func(ctx http.Context) error {
fmt.Println("/api/v2/user/me")
ctx.JSON(200, gin.H{
"asdasd": "asdasd",
})
return nil
})
app := kit.New(kit.Server(hs))
fmt.Println(app.Run())
fmt.Println(app.Stop())
}