mirror of
https://github.com/infinite-iroha/touka.git
synced 2026-07-31 06:48:18 +08:00
feat: add HTTP QUERY method support (RFC 10008)
- Add MethodQuery constant to touka.go - Add QUERY() convenience method to Engine and RouterGroup - Add examples/query/main.go demonstrating usage - All existing tests pass
This commit is contained in:
parent
d439662adf
commit
51ee66871f
3 changed files with 64 additions and 0 deletions
|
|
@ -733,6 +733,12 @@ func (engine *Engine) OPTIONS(relativePath string, handlers ...HandlerFunc) {
|
|||
engine.Handle(http.MethodOptions, relativePath, handlers...)
|
||||
}
|
||||
|
||||
// QUERY 注册 QUERY 方法的路由 (RFC 10008)
|
||||
// QUERY 方法是安全且幂等的,可以携带请求体,适用于复杂查询场景
|
||||
func (engine *Engine) QUERY(relativePath string, handlers ...HandlerFunc) {
|
||||
engine.Handle(MethodQuery, relativePath, handlers...)
|
||||
}
|
||||
|
||||
// ANY 注册所有常见 HTTP 方法的路由
|
||||
func (engine *Engine) ANY(relativePath string, handlers ...HandlerFunc) {
|
||||
engine.Handle(http.MethodGet, relativePath, handlers...)
|
||||
|
|
@ -804,6 +810,9 @@ func (group *RouterGroup) HEAD(relativePath string, handlers ...HandlerFunc) {
|
|||
func (group *RouterGroup) OPTIONS(relativePath string, handlers ...HandlerFunc) {
|
||||
group.Handle(http.MethodOptions, relativePath, handlers...)
|
||||
}
|
||||
func (group *RouterGroup) QUERY(relativePath string, handlers ...HandlerFunc) {
|
||||
group.Handle(MethodQuery, relativePath, handlers...)
|
||||
}
|
||||
func (group *RouterGroup) ANY(relativePath string, handlers ...HandlerFunc) {
|
||||
group.Handle(http.MethodGet, relativePath, handlers...)
|
||||
group.Handle(http.MethodPost, relativePath, handlers...)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue