add function handling (basic)
This commit is contained in:
@@ -1,10 +1,14 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"git.oblat.lv/alex/triggerssmith/api/invoke"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/config"
|
||||
"git.oblat.lv/alex/triggerssmith/internal/vars"
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
@@ -28,5 +32,16 @@ func (r *Router) RouteHandler() chi.Router {
|
||||
})
|
||||
fs := http.FileServer(http.Dir("static"))
|
||||
r.r.Handle("/static/*", http.StripPrefix("/static/", fs))
|
||||
r.r.Get("/health", func(w http.ResponseWriter, r *http.Request) {
|
||||
b, _ := json.Marshal(struct {
|
||||
Status string `json:"status"`
|
||||
Uptime string `json:"uptime"`
|
||||
}{
|
||||
Status: "ok",
|
||||
Uptime: time.Since(vars.START_TIME).String(),
|
||||
})
|
||||
w.Write([]byte(b))
|
||||
})
|
||||
r.r.Handle("/i/invoke/function/{function_id}/{function_version}", invoke.InvokeHandler(r.cfg))
|
||||
return r.r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user