goctl added

This commit is contained in:
kim
2020-07-29 17:11:41 +08:00
parent b1975d29a7
commit 121323b8c3
142 changed files with 10690 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
package handler
import (
"net/http"
"zero/core/httpx"
)
type (
request struct {
User string `form:"user,optional"`
}
response struct {
Code int `json:"code"`
Greet string `json:"greet"`
From string `json:"from,omitempty"`
}
)
func GreetHandler(w http.ResponseWriter, r *http.Request) {
var req request
err := httpx.Parse(r, &req)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
}
httpx.OkJson(w, response{
Code: 0,
Greet: "hello",
})
}