forked from gocraft/work
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Expose web ui router for external server, and switch to *http.S…
…erveMux from gocraft/web (#44) feat: Expose web ui router for external server, and switch to *http.ServeMux from gocraft/web - Update minimum supported golang version to 1.22 - Use explicit relative path on webui - Cleanup & refactoring --------- Co-authored-by: Anmol Chopra <anmol.chopra@gojek.com>
- Loading branch information
1 parent
53d536c
commit ad0f5c1
Showing
13 changed files
with
814 additions
and
332 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package webui | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gojek/work" | ||
) | ||
|
||
// NewHandler return *http.ServeMux for the given work.Client. | ||
// The web UI rely on relative path, so http.Handler should be mounted on a path with trailing `/`. | ||
// For example, if you want to mount the web UI on `/workerui`, you should use: | ||
// ``` | ||
// handler := webui.NewHandler(client) | ||
// mux.Handle("/workerui/", http.StripPrefix("/workerui", handler)) | ||
// ``` | ||
func NewHandler(client *work.Client) *http.ServeMux { | ||
ctx := context{client: client} | ||
|
||
mux := http.NewServeMux() | ||
mux.HandleFunc("GET /ping", ctx.ping) | ||
mux.HandleFunc("GET /queues", ctx.queues) | ||
mux.HandleFunc("GET /worker_pools", ctx.workerPools) | ||
mux.HandleFunc("GET /busy_workers", ctx.busyWorkers) | ||
mux.HandleFunc("GET /retry_jobs", ctx.retryJobs) | ||
mux.HandleFunc("GET /scheduled_jobs", ctx.scheduledJobs) | ||
mux.HandleFunc("GET /dead_jobs", ctx.deadJobs) | ||
mux.HandleFunc("POST /delete_dead_job/{died_at}/{job_id}", ctx.deleteDeadJob) | ||
mux.HandleFunc("POST /retry_dead_job/{died_at}/{job_id}", ctx.retryDeadJob) | ||
mux.HandleFunc("POST /delete_all_dead_jobs", ctx.deleteAllDeadJobs) | ||
mux.HandleFunc("POST /retry_all_dead_jobs", ctx.retryAllDeadJobs) | ||
mux.HandleFunc("GET /", ctx.indexPage) | ||
mux.HandleFunc("GET /work.js", ctx.workJS) | ||
|
||
return mux | ||
} |
Oops, something went wrong.