59 lines
2.4 KiB
Go
59 lines
2.4 KiB
Go
package httpserver
|
|
|
|
import (
|
|
core "git.yuntuo.hk/k2safe/orbit/model"
|
|
"git.yuntuo.hk/k2safe/orbit/platform/auth"
|
|
"git.yuntuo.hk/k2safe/orbit/weave/instance"
|
|
"git.yuntuo.hk/k2safe/orbit/weave/signal"
|
|
"net/http"
|
|
)
|
|
|
|
func registerWorkflowHistory(mux *http.ServeMux, instances *instance.Service, signals *signal.Service) {
|
|
mux.HandleFunc("GET /v1/workflows/{id}/steps/{key}/activations", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
|
in, err := historyQuery(r, true)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
out, err := instances.ListActivations(r.Context(), t, core.ID(r.PathValue("id")), r.PathValue("key"), in)
|
|
return out, 200, err
|
|
}))
|
|
mux.HandleFunc("GET /v1/workflows/{id}/steps/{key}/activations/{activation}", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
|
if _, err := historyQuery(r, false); err != nil {
|
|
return nil, 0, err
|
|
}
|
|
out, err := instances.GetActivation(r.Context(), t, core.ID(r.PathValue("id")), r.PathValue("key"), core.ID(r.PathValue("activation")))
|
|
return out, 200, err
|
|
}))
|
|
mux.HandleFunc("GET /v1/workflows/{id}/steps/{key}/activations/{activation}/rounds", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
|
in, err := historyQuery(r, true)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
out, err := instances.ListPollRounds(r.Context(), t, core.ID(r.PathValue("id")), r.PathValue("key"), core.ID(r.PathValue("activation")), in)
|
|
return out, 200, err
|
|
}))
|
|
mux.HandleFunc("GET /v1/workflows/{id}/signals", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
|
in, err := historyQuery(r, true)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
out, err := signals.List(r.Context(), t, core.ID(r.PathValue("id")), in)
|
|
return out, 200, err
|
|
}))
|
|
mux.HandleFunc("GET /v1/workflows/{id}/signals/{signal}/operations", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
|
in, err := historyQuery(r, true)
|
|
if err != nil {
|
|
return nil, 0, err
|
|
}
|
|
out, err := signals.ListOperations(r.Context(), t, core.ID(r.PathValue("id")), core.ID(r.PathValue("signal")), in)
|
|
return out, 200, err
|
|
}))
|
|
mux.HandleFunc("GET /v1/workflows/{id}/signals/{signal}/operations/{operation}", wrap(func(r *http.Request, t auth.Token) (any, int, error) {
|
|
if _, err := historyQuery(r, false); err != nil {
|
|
return nil, 0, err
|
|
}
|
|
out, err := signals.GetOperation(r.Context(), t, core.ID(r.PathValue("id")), core.ID(r.PathValue("signal")), core.ID(r.PathValue("operation")))
|
|
return out, 200, err
|
|
}))
|
|
}
|