asynqmon/example_test.go

33 lines
532 B
Go
Raw Normal View History

2021-10-03 07:34:21 +05:30
package asynqmon_test
import (
"embed"
"log"
"net/http"
"github.com/hibiken/asynq"
"github.com/hibiken/asynqmon"
)
//go:embed ui-assets/*
var staticContents embed.FS
func ExampleNewAPI() {
api := asynqmon.NewAPI(asynqmon.APIOptions{
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())
}