This commit is contained in:
2026-03-16 19:59:07 +03:00
commit c1935c8edb
8 changed files with 276 additions and 0 deletions

25
main.go Normal file
View File

@@ -0,0 +1,25 @@
package main
import (
"fmt"
"log"
"net/http"
)
func main() {
srv := NewServer(":5000")
srv.Handle("GET /", func(w http.ResponseWriter, r *http.Request) error {
return srv.JSON(w, struct {
Ok bool `json:"ok"`
}{true}, 200)
})
srv.Handle("GET /error", func(w http.ResponseWriter, r *http.Request) error {
return fmt.Errorf("not ok")
})
if err := srv.ListenAndServe(); err != nil {
log.Fatalf("failed to start http server: %v", err)
}
}