mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-09-22 06:46:34 +08:00
Serve both UI assets and REST API from handler
This commit is contained in:
@@ -4,27 +4,16 @@ import (
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/hibiken/asynqmon"
|
||||
)
|
||||
|
||||
func ExampleNew() {
|
||||
func ExampleHTTPHandler() {
|
||||
h := asynqmon.New(asynqmon.Options{
|
||||
RootPath: "/monitoring",
|
||||
RedisConnOpt: asynq.RedisClientOpt{Addr: ":6379"},
|
||||
})
|
||||
defer h.Close()
|
||||
|
||||
r := mux.NewRouter()
|
||||
r.PathPrefix("/api").Handler(h)
|
||||
// Add static content handler or other handlers
|
||||
// r.PathPrefix("/").Handler(h)
|
||||
|
||||
srv := &http.Server{
|
||||
Handler: r,
|
||||
Addr: ":8080",
|
||||
}
|
||||
|
||||
log.Fatal(srv.ListenAndServe())
|
||||
http.Handle(h.RootPath(), h)
|
||||
log.Fatal(http.ListenAndServe(":8000", nil)) // visit localhost:8000/monitoring to see asynqmon homepage
|
||||
}
|
||||
|
Reference in New Issue
Block a user