add usage documentation

This commit is contained in:
ajatprabha
2021-10-03 07:34:21 +05:30
committed by Ken Hibino
parent e04ec62920
commit bb2f7788f6
2 changed files with 80 additions and 0 deletions

32
example_test.go Normal file
View File

@@ -0,0 +1,32 @@
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())
}