http response tooling written

This commit is contained in:
2025-12-30 14:42:04 -07:00
parent 493d15eae8
commit c01d700482
14 changed files with 660 additions and 60 deletions
+18
View File
@@ -0,0 +1,18 @@
package response
import (
"net/http"
)
type HandlerFunc = func(r *http.Request) (Response, error)
func Handler(f HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
res, err := f(r)
if err != nil {
WriteError(w, err)
} else {
Write(w, r, res)
}
}
}