asynqmon/example_test.go

33 lines
545 B
Go
Raw Normal View History

2021-10-03 10:04:21 +08:00
package asynqmon_test
import (
"embed"
"log"
"net/http"
"github.com/hibiken/asynq"
"github.com/hibiken/asynqmon"
)
//go:embed ui-assets/*
var staticContents embed.FS
2021-10-04 02:30:40 +08:00
func ExampleNewHTTPHandler() {
api := asynqmon.NewHTTPHandler(asynqmon.Options{
2021-10-03 10:04:21 +08:00
RedisConnOpt: asynq.RedisClientOpt{Addr: ":6379"},
StaticContentHandler: asynqmon.NewStaticContentHandler(
staticContents,
"ui-assets",
"index.html",
),
})
defer api.Close()
srv := &http.Server{
Handler: api,
Addr: ":8080",
}
log.Fatal(srv.ListenAndServe())
}