feat: deliver authenticated task APIs, SDK and P1 regression
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
// Package httpserver exposes bootstrap health endpoints only. Task, workflow,
|
||||
// authentication and WebSocket APIs will be implemented in subsequent slices.
|
||||
// Package httpserver exposes health and authenticated task-management endpoints.
|
||||
package httpserver
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"git.yuntuo.hk/k2safe/orbit/pulse/service"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Checker func(context.Context) error
|
||||
|
||||
func New(addr string, ready Checker) *http.Server {
|
||||
func New(addr string, ready Checker, tasks ...*service.Service) *http.Server {
|
||||
mux := http.NewServeMux()
|
||||
write := func(w http.ResponseWriter, status int, body map[string]string) {
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
@@ -30,5 +30,8 @@ func New(addr string, ready Checker) *http.Server {
|
||||
}
|
||||
write(w, http.StatusOK, map[string]string{"status": "ready", "scope": "database_and_schema"})
|
||||
})
|
||||
return &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second, ReadTimeout: 10 * time.Second, WriteTimeout: 10 * time.Second, IdleTimeout: 60 * time.Second, MaxHeaderBytes: 16 << 10}
|
||||
if len(tasks) > 0 && tasks[0] != nil {
|
||||
registerTasks(mux, tasks[0])
|
||||
}
|
||||
return &http.Server{Addr: addr, Handler: mux, ReadHeaderTimeout: 5 * time.Second, ReadTimeout: 10 * time.Second, WriteTimeout: 15 * time.Second, IdleTimeout: 60 * time.Second, MaxHeaderBytes: 16 << 10}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user