mirror of
https://github.com/hibiken/asynqmon.git
synced 2025-09-22 06:46:34 +08:00
remove NewStaticContentHandlerFunc
This commit is contained in:
12
handler.go
12
handler.go
@@ -10,15 +10,10 @@ import (
|
||||
"github.com/hibiken/asynq"
|
||||
)
|
||||
|
||||
// MiddlewareFunc helps chain http.Handler(s).
|
||||
type MiddlewareFunc func(http.Handler) http.Handler
|
||||
|
||||
// Options can be used to customise HTTPHandler.
|
||||
type Options struct {
|
||||
RedisConnOpt asynq.RedisConnOpt
|
||||
Middlewares []MiddlewareFunc
|
||||
PayloadFormatter PayloadFormatter
|
||||
StaticContentHandler http.Handler
|
||||
}
|
||||
|
||||
// HTTPHandler can serve the API and UI required for asynq monitoring.
|
||||
@@ -32,7 +27,7 @@ func (a *HTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
a.router.ServeHTTP(w, r)
|
||||
}
|
||||
|
||||
// New creates an HTTPHandler that can be used to serve asynqmon web API with static contents.
|
||||
// New creates an HTTPHandler that can be used to serve asynqmon web API, it is prefixed with `/api`.
|
||||
func New(opts Options) *HTTPHandler {
|
||||
rc, ok := opts.RedisConnOpt.MakeRedisClient().(redis.UniversalClient)
|
||||
if !ok {
|
||||
@@ -61,10 +56,6 @@ func muxRouter(opts Options, rc redis.UniversalClient, inspector *asynq.Inspecto
|
||||
pf = opts.PayloadFormatter
|
||||
}
|
||||
|
||||
for _, mf := range opts.Middlewares {
|
||||
router.Use(mux.MiddlewareFunc(mf))
|
||||
}
|
||||
|
||||
api := router.PathPrefix("/api").Subrouter()
|
||||
// Queue endpoints.
|
||||
api.HandleFunc("/queues", newListQueuesHandlerFunc(inspector)).Methods("GET")
|
||||
@@ -137,6 +128,5 @@ func muxRouter(opts Options, rc redis.UniversalClient, inspector *asynq.Inspecto
|
||||
api.HandleFunc("/redis_info", newRedisInfoHandlerFunc(c)).Methods("GET")
|
||||
}
|
||||
|
||||
router.PathPrefix("/").Handler(opts.StaticContentHandler)
|
||||
return router
|
||||
}
|
||||
|
Reference in New Issue
Block a user