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

Function orgAssignment

internal/route/api/v1/api.go:74–105  ·  view source on GitHub ↗

orgAssignment extracts information from URL parameters to retrieve the organization or team.

(args ...bool)

Source from the content-addressed store, hash-verified

72
73// orgAssignment extracts information from URL parameters to retrieve the organization or team.
74func orgAssignment(args ...bool) macaron.Handler {
75 var (
76 assignOrg bool
77 assignTeam bool
78 )
79 if len(args) > 0 {
80 assignOrg = args[0]
81 }
82 if len(args) > 1 {
83 assignTeam = args[1]
84 }
85 return func(c *context.APIContext) {
86 c.Org = new(context.APIOrganization)
87
88 var err error
89 if assignOrg {
90 c.Org.Organization, err = database.Handle.Users().GetByUsername(c.Req.Context(), c.Params(":orgname"))
91 if err != nil {
92 c.NotFoundOrError(err, "get organization by name")
93 return
94 }
95 }
96
97 if assignTeam {
98 c.Org.Team, err = database.GetTeamByID(c.ParamsInt64(":teamid"))
99 if err != nil {
100 c.NotFoundOrError(err, "get team by ID")
101 return
102 }
103 }
104 }
105}
106
107// reqToken makes sure the context user is authorized via access token.
108func reqToken() macaron.Handler {

Callers 1

RegisterRoutesFunction · 0.85

Calls 4

GetTeamByIDFunction · 0.92
GetByUsernameMethod · 0.80
UsersMethod · 0.80
NotFoundOrErrorMethod · 0.45

Tested by

no test coverage detected