mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-09-22 06:46:34 +08:00
add usage documentation
This commit is contained in:
32
example_test.go
Normal file
32
example_test.go
Normal 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())
|
||||
}
|
Reference in New Issue
Block a user