summaryrefslogtreecommitdiff
path: root/engine.go
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-12-03 16:10:50 +0800
committerEltrac <hi@guhub.cn>2025-12-03 16:10:50 +0800
commit054f9b22b0f72b703f3f05434a026b280a6692ae (patch)
tree3d76af8cf7605fc8774717cf5681e38807c5a7d3 /engine.go
parenta7f5c63a22b8ee35545dbfe2bf8931cb5af8fe23 (diff)
feat: provide basic data getters
- c.Query(), from URL query string - c.PostFormValue(), from POST form - c.FormValue(), from both URL query and POST form - c.BindJSON(), from request body
Diffstat (limited to 'engine.go')
-rw-r--r--engine.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/engine.go b/engine.go
index 6fc1060..4d44fa1 100644
--- a/engine.go
+++ b/engine.go
@@ -38,11 +38,19 @@ func (a *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request) {
http.NotFound(w, req)
return
}
+
+ err := req.ParseForm()
+ if err != nil {
+ http.Error(w, err.Error(), http.StatusBadRequest)
+ return
+ }
+
handler(&Context{
W: w,
R: req,
Params: params,
Querys: req.URL.Query(),
+ Form: req.Form,
})
}