Update README.md : example with gin framework

This commit is contained in:
Abbas Momeni 2024-12-20 19:14:18 +03:30 committed by GitHub
parent d1b889456d
commit 9d06847248
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -212,7 +212,7 @@ func main() {
RedisConnOpt: asynq.RedisClientOpt{Addr: ":6379"},
})
// Note: We need the tailing slash when using net/http.ServeMux.
// Note: We need the tailing slash when using net/http.ServeMux.
http.Handle(h.RootPath()+"/", h)
// Go to http://localhost:8080/monitoring to see asynqmon homepage.
@ -253,7 +253,7 @@ func main() {
}
```
Example with [labstack/echo](https://github.com/labstack/echo)):
Example with [labstack/echo](https://github.com/labstack/echo):
```go
@ -266,7 +266,7 @@ import (
)
func main() {
e := echo.New()
e := echo.New()
mon := asynqmon.New(asynqmon.Options{
RootPath: "/monitoring/tasks",
@ -282,6 +282,38 @@ func main() {
```
Example with [gin-gonic/gin](https://github.com/gin-gonic/gin):
```go
package main
import (
"github.com/gin-gonic/gin"
"github.com/hibiken/asynq"
"github.com/hibiken/asynqmon"
"log"
)
func main() {
h := asynqmon.New(asynqmon.Options{
RootPath: "/monitoring",
RedisConnOpt: asynq.RedisClientOpt{Addr: ":6379"},
})
r := gin.Default()
r.Any(h.RootPath()+"/*any", gin.WrapH(h))
if err := r.Run(":8080"); err != nil {
log.Fatal("Server failed to start:", err)
}
}
```
## License
Copyright (c) 2019-present [Ken Hibino](https://github.com/hibiken) and [Contributors](https://github.com/hibiken/asynqmon/graphs/contributors). `Asynqmon` is free and open-source software licensed under the [MIT License](https://github.com/hibiken/asynq/blob/master/LICENSE). Official logo was created by [Vic Shóstak](https://github.com/koddr) and distributed under [Creative Commons](https://creativecommons.org/publicdomain/zero/1.0/) license (CC0 1.0 Universal).