Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Feb 13, 2020
1 parent a4d0b4e commit 6944636
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions README-ZH.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ router.ErrorHandler = MyErrorHandler{

```go
authenticator := func(ctx *clevergo.Context) error {
// authenticate 返回一个 user 和一个布尔值表示提供的凭证是否有效。
if user, ok := authenticate(ctx); !ok {
// 返回一个错误,以终止后续的中间件和 Handle。
return clevergo.StatusError{http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)}
}
// authenticate 返回一个 user 和一个布尔值表示提供的凭证是否有效。
if user, ok := authenticate(ctx); !ok {
// 返回一个错误,以终止后续的中间件和 Handle。
return clevergo.StatusError{http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)}
}

// 在中间件之间共享数据。
// 在中间件之间共享数据。
ctx.WithValue("user", user)
return nil
}
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ Middleware is a `Handle`.

```go
authenticator := func(ctx *clevergo.Context) error {
// authenticate returns an user instance and a boolean value indicates whether the provided credential is valid.
if user, ok := authenticate(ctx); !ok {
// returns an error if failed, in order to stop subsequent middlewares and handle.
return clevergo.StatusError{http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)}
}
// authenticate returns an user instance and a boolean value indicates whether the provided credential is valid.
if user, ok := authenticate(ctx); !ok {
// returns an error if failed, in order to stop subsequent middlewares and handle.
return clevergo.StatusError{http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized)}
}

// share data between middlewares and handle.
// share data between middlewares and handle.
ctx.WithValue("user", user)
return nil
}
Expand Down

0 comments on commit 6944636

Please sign in to comment.