Skip to content

Commit

Permalink
Add status endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter committed Jun 12, 2024
1 parent 08806a1 commit 0d9eec9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions trusted_applet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,17 @@ func runWithNetworking(ctx context.Context) error {
w.Header().Add("Content-Type", "text/plain")
w.Write([]byte("ok, check /consolelog!"))
})
srvMux.HandleFunc("/status", func(w http.ResponseWriter, _ *http.Request) {
var s api.Status
if err := syscall.Call("RPC.Status", nil, &s); err != nil {
w.Header().Add("Content-Type", "text/plain")
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
w.Header().Add("Content-Type", "text/plain")
w.Write([]byte(s.Print()))
})
srv := &http.Server{
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
Expand Down

0 comments on commit 0d9eec9

Please sign in to comment.