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