Skip to content

Commit

Permalink
Add status endpoint (#312)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlCutter authored Jun 13, 2024
1 parent 5e04332 commit 536fd5f
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 @@ -328,6 +328,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 536fd5f

Please sign in to comment.