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.

39 lines
779 B

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