Skip to content

Commit 2869b37

Browse files
committed
####Version 1.7.16
* Bug fix: fix middleware chain misbehaving in netsed groups * Tips: for issue #234, thanks for @LiVe's code * 2021-01-24 22:00 at ShangHai
1 parent 281f481 commit 2869b37

File tree

2 files changed

+25
-24
lines changed

2 files changed

+25
-24
lines changed

README.md

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ go get github.com/devfeel/dotweb
2323
```
2424

2525
## 2. Getting Started
26-
```go
26+
``` go
2727
package main
2828

2929
import (
@@ -58,6 +58,7 @@ func main() {
5858
* Feature支持,可绑定HttpServer全局启用
5959
* 支持STRING/JSON/JSONP/HTML格式输出
6060
* 集成Mock能力
61+
* 支持自定义Context
6162
* 集成Timeout Hook
6263
* 全局HTTP错误处理
6364
* 全局日志处理
@@ -103,26 +104,26 @@ cpu | 内存 | Samples | Average | Median | 90%Line | 95%Line | 99%Line | Min |
103104
* 支持通过配置开启默认添加HEAD方式
104105
* 支持注册Handler,以启用配置化
105106
* 支持检查请求与指定路由是否匹配
106-
```go
107-
1Router.GET(path string, handle HttpHandle)
108-
2Router.POST(path string, handle HttpHandle)
109-
3Router.HEAD(path string, handle HttpHandle)
110-
4Router.OPTIONS(path string, handle HttpHandle)
111-
5Router.PUT(path string, handle HttpHandle)
112-
6Router.PATCH(path string, handle HttpHandle)
113-
7Router.DELETE(path string, handle HttpHandle)
114-
8Router.HiJack(path string, handle HttpHandle)
115-
9Router.WebSocket(path string, handle HttpHandle)
116-
10Router.Any(path string, handle HttpHandle)
117-
11Router.RegisterRoute(routeMethod string, path string, handle HttpHandle)
118-
12Router.RegisterHandler(name string, handler HttpHandle)
119-
13Router.GetHandler(name string) (HttpHandle, bool)
120-
14Router.MatchPath(ctx Context, routePath string) bool
107+
``` go
108+
Router.GET(path string, handle HttpHandle)
109+
Router.POST(path string, handle HttpHandle)
110+
Router.HEAD(path string, handle HttpHandle)
111+
Router.OPTIONS(path string, handle HttpHandle)
112+
Router.PUT(path string, handle HttpHandle)
113+
Router.PATCH(path string, handle HttpHandle)
114+
Router.DELETE(path string, handle HttpHandle)
115+
Router.HiJack(path string, handle HttpHandle)
116+
Router.WebSocket(path string, handle HttpHandle)
117+
Router.Any(path string, handle HttpHandle)
118+
Router.RegisterRoute(routeMethod string, path string, handle HttpHandle)
119+
Router.RegisterHandler(name string, handler HttpHandle)
120+
Router.GetHandler(name string) (HttpHandle, bool)
121+
Router.MatchPath(ctx Context, routePath string) bool
121122
```
122123
接受两个参数,一个是URI路径,另一个是 HttpHandle 类型,设定匹配到该路径时执行的方法;
123124
#### 2) static router
124125
静态路由语法就是没有任何参数变量,pattern是一个固定的字符串。
125-
```go
126+
``` go
126127
package main
127128

128129
import (
@@ -141,7 +142,7 @@ test:
141142
curl http://127.0.0.1/hello
142143
#### 3) parameter router
143144
参数路由以冒号 : 后面跟一个字符串作为参数名称,可以通过 HttpContext的 GetRouterName 方法获取路由参数的值。
144-
```go
145+
``` go
145146
package main
146147

147148
import (
@@ -165,7 +166,7 @@ test:
165166
<br>curl http://127.0.0.1/hello/devfeel
166167
<br>curl http://127.0.0.1/hello/category1/1
167168
#### 4) group router
168-
```go
169+
``` go
169170
g := server.Group("/user")
170171
g.GET("/", Index)
171172
g.GET("/profile", Profile)
@@ -178,7 +179,7 @@ test:
178179
## 6. Binder
179180
* HttpContext.Bind(interface{})
180181
* Support data from json、xml、Form
181-
```go
182+
``` go
182183
type UserInfo struct {
183184
UserName string `form:"user"`
184185
Sex int `form:"sex"`
@@ -213,7 +214,7 @@ func TestBind(ctx dotweb.HttpContext) error{
213214
* Recover
214215
* HeaderOverride
215216

216-
```go
217+
``` go
217218
app.Use(NewAccessFmtLog("app"))
218219

219220
func InitRoute(server *dotweb.HttpServer) {
@@ -286,13 +287,13 @@ func NewAccessFmtLog(index string) *AccessFmtLog {
286287
#### 500 error
287288
* Default: 当发生未处理异常时,会根据RunMode向页面输出默认错误信息或者具体异常信息,并返回 500 错误头
288289
* User-defined: 通过DotServer.SetExceptionHandle(handler *ExceptionHandle)实现自定义异常处理逻辑
289-
```go
290+
``` go
290291
type ExceptionHandle func(Context, error)
291292
```
292293
#### 404 error
293294
* Default: 当发生404异常时,会默认使用http.NotFound处理
294295
* User-defined: 通过DotWeb.SetNotFoundHandle(handler NotFoundHandle)实现自定义404处理逻辑
295-
```go
296+
``` go
296297
type NotFoundHandle func(http.ResponseWriter, *http.Request)
297298
```
298299

version.MD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* refactor: add defaultContextCreater used to create Context with HttpContext when HttpServer.ServeHTTP
1313
* example code: example/main.go
1414
* How to use SetContextCreater:
15-
~~~
15+
~~~ go
1616
// define
1717
type testContext struct {
1818
dotweb.HttpContext

0 commit comments

Comments
 (0)