Skip to content

Commit

Permalink
feat: allow to reset gnodev with endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz committed May 27, 2024
1 parent 4c3ae6e commit cbd14a7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions contribs/gnodev/cmd/gnodev/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ func execDev(cfg *devCfg, args []string, io commands.IO) (err error) {
// Setup gnoweb
webhandler := setupGnoWebServer(logger.WithGroup(WebLogName), cfg, devNode)

mux.HandleFunc("/reset", func(res http.ResponseWriter, req *http.Request) {
if err := devNode.Reset(req.Context()); err != nil {
logger.Error("failed to reset", slog.Any("err", err))
res.WriteHeader(http.StatusInternalServerError)
}
})

// Setup HotReload if needed
if !cfg.noWatch {
evtstarget := fmt.Sprintf("%s/_events", server.Addr)
Expand Down

0 comments on commit cbd14a7

Please sign in to comment.