Files
monkey/internal/server/handlers.go
Chuck Smith 07fd82b261
Some checks failed
Build / build (push) Successful in 10m29s
Publish Image / publish (push) Failing after 31s
Test / build (push) Failing after 6m34s
optimizations
2024-04-02 14:08:08 -04:00

35 lines
697 B
Go

package server
import (
"fmt"
"io"
"monkey"
"net/http"
"go.mills.io/router"
)
func (s *Server) runHandler() router.Handle {
return func(w http.ResponseWriter, r *http.Request, p router.Params) {
opts := &monkey.Options{
Stdout: w,
Stderr: w,
Exit: func(status int) {
io.WriteString(w, fmt.Sprintf("<p><i>Program exited with %d.</i></p>", status))
},
}
err := monkey.ExecString(r.FormValue("code"), opts)
if err != nil {
http.Error(w, err.Error(), 400)
return
}
}
}
func (s *Server) formatHandler() router.Handle {
return func(w http.ResponseWriter, r *http.Request, p router.Params) {
http.Error(w, "Not Implemented", http.StatusNotImplemented)
}
}