InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username', and injects it as *ParamsUser.
()
| 14 | // InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username', |
| 15 | // and injects it as *ParamsUser. |
| 16 | func InjectParamsUser() macaron.Handler { |
| 17 | return func(c *Context) { |
| 18 | user, err := database.Handle.Users().GetByUsername(c.Req.Context(), c.Params(":username")) |
| 19 | if err != nil { |
| 20 | c.NotFoundOrError(err, "get user by name") |
| 21 | return |
| 22 | } |
| 23 | c.Map(&ParamsUser{user}) |
| 24 | } |
| 25 | } |
no test coverage detected