MCPcopy Create free account
hub / github.com/gogs/gogs / InjectParamsUser

Function InjectParamsUser

internal/context/user.go:16–25  ·  view source on GitHub ↗

InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username', and injects it as *ParamsUser.

()

Source from the content-addressed store, hash-verified

14// InjectParamsUser returns a handler that retrieves target user based on URL parameter ':username',
15// and injects it as *ParamsUser.
16func 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}

Callers 1

runWebFunction · 0.92

Calls 3

GetByUsernameMethod · 0.80
UsersMethod · 0.80
NotFoundOrErrorMethod · 0.45

Tested by

no test coverage detected