You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

api.go 16 kB

Add basic integration test infrastructure (and new endpoint `/api/v1/version` for testing it) (#741) * Implement '/api/v1/version' * Cleanup and various fixes * Enhance run.sh * Add install_test.go * Add parameter utils.Config for testing handlers * Re-organize TestVersion.go * Rename functions * handling process cleanup properly * Fix missing function renaming * Cleanup the 'retry' logic * Cleanup * Remove unneeded logging code * Logging messages tweaking * Logging message tweaking * Fix logging messages * Use 'const' instead of hardwired numbers * We don't really need retries anymore * Move constant ServerHttpPort to install_test.go * Restore mistakenly removed constant * Add required comments to make the linter happy. * Fix comments and naming to address linter's complaints * Detect Gitea executale version automatically * Remove tests/run.sh, `go test` suffices. * Make `make build` a prerequisite of `make test` * Do not sleep before trying * Speedup the server pinging loop * Use defined const instead of hardwired numbers * Remove redundant error handling * Use a dedicated target for running code.gitea.io/tests * Do not make 'test' depend on 'build' target * Rectify the excluded package list * Remove redundant 'exit 1' * Change the API to allow passing test.T to test handlers * Make testing.T an embedded field * Use assert.Equal to comparing results * Add copyright info * Parametrized logging output * Use tmpdir instead * Eliminate redundant casting * Remove unneeded variable * Fix last commit * Add missing copyright info * Replace fmt.Fprintf with fmt.Fprint * rename the xtest to integration-test * Use Symlink instead of hard-link for cross-device linking * Turn debugging logs on * Follow the existing framework for APIs * Output logs only if test.v is true * Re-order import statements * Enhance the error message * Fix comment which breaks the linter's rule * Rename 'integration-test' to 'e2e-test' for saving keystrokes * Add comment to avoid possible confusion * Rename tests -> integration-tests Also change back the Makefile to use `make integration-test`. * Use tests/integration for now * tests/integration -> integrations Slightly flattened directory hierarchy is better. * Update Makefile accordingly * Fix a missing change in Makefile * govendor update code.gitea.io/sdk/gitea * Fix comment of struct fields * Fix conditional nonsense * Fix missing updates regarding version string changes * Make variable naming more consistent * Check http status code * Rectify error messages
8 years ago
10 years ago
9 years ago
10 years ago
10 years ago
8 years ago
8 years ago
8 years ago
8 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. // Copyright 2015 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. // Package v1 Gitea API.
  5. //
  6. // This provide API interface to communicate with this Gitea instance.
  7. //
  8. // Terms Of Service:
  9. //
  10. // there are no TOS at this moment, use at your own risk we take no responsibility
  11. //
  12. // Schemes: http, https
  13. // BasePath: /api/v1
  14. // Version: 1.1.1
  15. // License: MIT http://opensource.org/licenses/MIT
  16. //
  17. // Consumes:
  18. // - application/json
  19. // - text/plain
  20. //
  21. // Produces:
  22. // - application/json
  23. // - text/html
  24. //
  25. // Security:
  26. // - BasicAuth: []
  27. // - Token: []
  28. // - AccessToken: []
  29. // - AuthorizationHeaderToken: []
  30. //
  31. // SecurityDefinitions:
  32. // BasicAuth:
  33. // type: basic
  34. // Token:
  35. // type: apiKey
  36. // name: token
  37. // in: query
  38. // AccessToken:
  39. // type: apiKey
  40. // name: access_token
  41. // in: query
  42. // AuthorizationHeaderToken:
  43. // type: apiKey
  44. // name: Authorization
  45. // in: header
  46. //
  47. // swagger:meta
  48. package v1
  49. import (
  50. "strings"
  51. "github.com/go-macaron/binding"
  52. "gopkg.in/macaron.v1"
  53. api "code.gitea.io/sdk/gitea"
  54. "code.gitea.io/gitea/models"
  55. "code.gitea.io/gitea/modules/auth"
  56. "code.gitea.io/gitea/modules/context"
  57. "code.gitea.io/gitea/routers/api/v1/admin"
  58. "code.gitea.io/gitea/routers/api/v1/misc"
  59. "code.gitea.io/gitea/routers/api/v1/org"
  60. "code.gitea.io/gitea/routers/api/v1/repo"
  61. "code.gitea.io/gitea/routers/api/v1/user"
  62. "code.gitea.io/gitea/routers/api/v1/utils"
  63. )
  64. func repoAssignment() macaron.Handler {
  65. return func(ctx *context.APIContext) {
  66. userName := ctx.Params(":username")
  67. repoName := ctx.Params(":reponame")
  68. var (
  69. owner *models.User
  70. err error
  71. )
  72. // Check if the user is the same as the repository owner.
  73. if ctx.IsSigned && ctx.User.LowerName == strings.ToLower(userName) {
  74. owner = ctx.User
  75. } else {
  76. owner, err = models.GetUserByName(userName)
  77. if err != nil {
  78. if models.IsErrUserNotExist(err) {
  79. ctx.Status(404)
  80. } else {
  81. ctx.Error(500, "GetUserByName", err)
  82. }
  83. return
  84. }
  85. }
  86. ctx.Repo.Owner = owner
  87. // Get repository.
  88. repo, err := models.GetRepositoryByName(owner.ID, repoName)
  89. if err != nil {
  90. if models.IsErrRepoNotExist(err) {
  91. redirectRepoID, err := models.LookupRepoRedirect(owner.ID, repoName)
  92. if err == nil {
  93. context.RedirectToRepo(ctx.Context, redirectRepoID)
  94. } else if models.IsErrRepoRedirectNotExist(err) {
  95. ctx.Status(404)
  96. } else {
  97. ctx.Error(500, "LookupRepoRedirect", err)
  98. }
  99. } else {
  100. ctx.Error(500, "GetRepositoryByName", err)
  101. }
  102. return
  103. }
  104. repo.Owner = owner
  105. if ctx.IsSigned && ctx.User.IsAdmin {
  106. ctx.Repo.AccessMode = models.AccessModeOwner
  107. } else {
  108. mode, err := models.AccessLevel(utils.UserID(ctx), repo)
  109. if err != nil {
  110. ctx.Error(500, "AccessLevel", err)
  111. return
  112. }
  113. ctx.Repo.AccessMode = mode
  114. }
  115. if !ctx.Repo.HasAccess() {
  116. ctx.Status(404)
  117. return
  118. }
  119. ctx.Repo.Repository = repo
  120. }
  121. }
  122. // Contexter middleware already checks token for user sign in process.
  123. func reqToken() macaron.Handler {
  124. return func(ctx *context.Context) {
  125. if !ctx.IsSigned {
  126. ctx.Error(401)
  127. return
  128. }
  129. }
  130. }
  131. func reqBasicAuth() macaron.Handler {
  132. return func(ctx *context.Context) {
  133. if !ctx.IsBasicAuth {
  134. ctx.Error(401)
  135. return
  136. }
  137. }
  138. }
  139. func reqAdmin() macaron.Handler {
  140. return func(ctx *context.Context) {
  141. if !ctx.IsSigned || !ctx.User.IsAdmin {
  142. ctx.Error(403)
  143. return
  144. }
  145. }
  146. }
  147. func reqRepoWriter() macaron.Handler {
  148. return func(ctx *context.Context) {
  149. if !ctx.Repo.IsWriter() {
  150. ctx.Error(403)
  151. return
  152. }
  153. }
  154. }
  155. func reqOrgMembership() macaron.Handler {
  156. return func(ctx *context.APIContext) {
  157. var orgID int64
  158. if ctx.Org.Organization != nil {
  159. orgID = ctx.Org.Organization.ID
  160. } else if ctx.Org.Team != nil {
  161. orgID = ctx.Org.Team.OrgID
  162. } else {
  163. ctx.Error(500, "", "reqOrgMembership: unprepared context")
  164. return
  165. }
  166. if !models.IsOrganizationMember(orgID, ctx.User.ID) {
  167. if ctx.Org.Organization != nil {
  168. ctx.Error(403, "", "Must be an organization member")
  169. } else {
  170. ctx.Status(404)
  171. }
  172. return
  173. }
  174. }
  175. }
  176. func reqOrgOwnership() macaron.Handler {
  177. return func(ctx *context.APIContext) {
  178. var orgID int64
  179. if ctx.Org.Organization != nil {
  180. orgID = ctx.Org.Organization.ID
  181. } else if ctx.Org.Team != nil {
  182. orgID = ctx.Org.Team.OrgID
  183. } else {
  184. ctx.Error(500, "", "reqOrgOwnership: unprepared context")
  185. return
  186. }
  187. if !models.IsOrganizationOwner(orgID, ctx.User.ID) {
  188. if ctx.Org.Organization != nil {
  189. ctx.Error(403, "", "Must be an organization owner")
  190. } else {
  191. ctx.Status(404)
  192. }
  193. return
  194. }
  195. }
  196. }
  197. func orgAssignment(args ...bool) macaron.Handler {
  198. var (
  199. assignOrg bool
  200. assignTeam bool
  201. )
  202. if len(args) > 0 {
  203. assignOrg = args[0]
  204. }
  205. if len(args) > 1 {
  206. assignTeam = args[1]
  207. }
  208. return func(ctx *context.APIContext) {
  209. ctx.Org = new(context.APIOrganization)
  210. var err error
  211. if assignOrg {
  212. ctx.Org.Organization, err = models.GetOrgByName(ctx.Params(":orgname"))
  213. if err != nil {
  214. if models.IsErrOrgNotExist(err) {
  215. ctx.Status(404)
  216. } else {
  217. ctx.Error(500, "GetOrgByName", err)
  218. }
  219. return
  220. }
  221. }
  222. if assignTeam {
  223. ctx.Org.Team, err = models.GetTeamByID(ctx.ParamsInt64(":teamid"))
  224. if err != nil {
  225. if models.IsErrUserNotExist(err) {
  226. ctx.Status(404)
  227. } else {
  228. ctx.Error(500, "GetTeamById", err)
  229. }
  230. return
  231. }
  232. }
  233. }
  234. }
  235. func mustEnableIssues(ctx *context.APIContext) {
  236. if !ctx.Repo.Repository.UnitEnabled(models.UnitTypeIssues) {
  237. ctx.Status(404)
  238. return
  239. }
  240. }
  241. func mustAllowPulls(ctx *context.Context) {
  242. if !ctx.Repo.Repository.AllowsPulls() {
  243. ctx.Status(404)
  244. return
  245. }
  246. }
  247. // RegisterRoutes registers all v1 APIs routes to web application.
  248. // FIXME: custom form error response
  249. func RegisterRoutes(m *macaron.Macaron) {
  250. bind := binding.Bind
  251. m.Group("/v1", func() {
  252. // Miscellaneous
  253. m.Get("/version", misc.Version)
  254. m.Post("/markdown", bind(api.MarkdownOption{}), misc.Markdown)
  255. m.Post("/markdown/raw", misc.MarkdownRaw)
  256. // Users
  257. m.Group("/users", func() {
  258. m.Get("/search", user.Search)
  259. m.Group("/:username", func() {
  260. m.Get("", user.GetInfo)
  261. m.Get("/repos", user.ListUserRepos)
  262. m.Group("/tokens", func() {
  263. m.Combo("").Get(user.ListAccessTokens).
  264. Post(bind(api.CreateAccessTokenOption{}), user.CreateAccessToken)
  265. }, reqBasicAuth())
  266. })
  267. })
  268. m.Group("/users", func() {
  269. m.Group("/:username", func() {
  270. m.Get("/keys", user.ListPublicKeys)
  271. m.Get("/gpg_keys", user.ListGPGKeys)
  272. m.Get("/followers", user.ListFollowers)
  273. m.Group("/following", func() {
  274. m.Get("", user.ListFollowing)
  275. m.Get("/:target", user.CheckFollowing)
  276. })
  277. m.Get("/starred", user.GetStarredRepos)
  278. m.Get("/subscriptions", user.GetWatchedRepos)
  279. })
  280. }, reqToken())
  281. m.Group("/user", func() {
  282. m.Get("", user.GetAuthenticatedUser)
  283. m.Combo("/emails").Get(user.ListEmails).
  284. Post(bind(api.CreateEmailOption{}), user.AddEmail).
  285. Delete(bind(api.CreateEmailOption{}), user.DeleteEmail)
  286. m.Get("/followers", user.ListMyFollowers)
  287. m.Group("/following", func() {
  288. m.Get("", user.ListMyFollowing)
  289. m.Combo("/:username").Get(user.CheckMyFollowing).Put(user.Follow).Delete(user.Unfollow)
  290. })
  291. m.Group("/keys", func() {
  292. m.Combo("").Get(user.ListMyPublicKeys).
  293. Post(bind(api.CreateKeyOption{}), user.CreatePublicKey)
  294. m.Combo("/:id").Get(user.GetPublicKey).
  295. Delete(user.DeletePublicKey)
  296. })
  297. m.Group("/gpg_keys", func() {
  298. m.Combo("").Get(user.ListMyGPGKeys).
  299. Post(bind(api.CreateGPGKeyOption{}), user.CreateGPGKey)
  300. m.Combo("/:id").Get(user.GetGPGKey).
  301. Delete(user.DeleteGPGKey)
  302. })
  303. m.Combo("/repos").Get(user.ListMyRepos).
  304. Post(bind(api.CreateRepoOption{}), repo.Create)
  305. m.Group("/starred", func() {
  306. m.Get("", user.GetMyStarredRepos)
  307. m.Group("/:username/:reponame", func() {
  308. m.Get("", user.IsStarring)
  309. m.Put("", user.Star)
  310. m.Delete("", user.Unstar)
  311. }, repoAssignment())
  312. })
  313. m.Get("/subscriptions", user.GetMyWatchedRepos)
  314. }, reqToken())
  315. // Repositories
  316. m.Post("/org/:org/repos", reqToken(), bind(api.CreateRepoOption{}), repo.CreateOrgRepo)
  317. m.Group("/repos", func() {
  318. m.Get("/search", repo.Search)
  319. })
  320. m.Combo("/repositories/:id", reqToken()).Get(repo.GetByID)
  321. m.Group("/repos", func() {
  322. m.Post("/migrate", reqToken(), bind(auth.MigrateRepoForm{}), repo.Migrate)
  323. m.Group("/:username/:reponame", func() {
  324. m.Combo("").Get(repo.Get).Delete(reqToken(), repo.Delete)
  325. m.Group("/hooks", func() {
  326. m.Combo("").Get(repo.ListHooks).
  327. Post(bind(api.CreateHookOption{}), repo.CreateHook)
  328. m.Combo("/:id").Get(repo.GetHook).
  329. Patch(bind(api.EditHookOption{}), repo.EditHook).
  330. Delete(repo.DeleteHook)
  331. }, reqToken(), reqRepoWriter())
  332. m.Group("/collaborators", func() {
  333. m.Get("", repo.ListCollaborators)
  334. m.Combo("/:collaborator").Get(repo.IsCollaborator).
  335. Put(bind(api.AddCollaboratorOption{}), repo.AddCollaborator).
  336. Delete(repo.DeleteCollaborator)
  337. }, reqToken())
  338. m.Get("/raw/*", context.RepoRef(), repo.GetRawFile)
  339. m.Get("/archive/*", repo.GetArchive)
  340. m.Combo("/forks").Get(repo.ListForks).
  341. Post(reqToken(), bind(api.CreateForkOption{}), repo.CreateFork)
  342. m.Group("/branches", func() {
  343. m.Get("", repo.ListBranches)
  344. m.Get("/*", context.RepoRef(), repo.GetBranch)
  345. })
  346. m.Group("/keys", func() {
  347. m.Combo("").Get(repo.ListDeployKeys).
  348. Post(bind(api.CreateKeyOption{}), repo.CreateDeployKey)
  349. m.Combo("/:id").Get(repo.GetDeployKey).
  350. Delete(repo.DeleteDeploykey)
  351. }, reqToken(), reqRepoWriter())
  352. m.Group("/issues", func() {
  353. m.Combo("").Get(repo.ListIssues).
  354. Post(reqToken(), bind(api.CreateIssueOption{}), repo.CreateIssue)
  355. m.Group("/comments", func() {
  356. m.Get("", repo.ListRepoIssueComments)
  357. m.Combo("/:id", reqToken()).
  358. Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment)
  359. })
  360. m.Group("/:index", func() {
  361. m.Combo("").Get(repo.GetIssue).
  362. Patch(reqToken(), bind(api.EditIssueOption{}), repo.EditIssue)
  363. m.Group("/comments", func() {
  364. m.Combo("").Get(repo.ListIssueComments).
  365. Post(reqToken(), bind(api.CreateIssueCommentOption{}), repo.CreateIssueComment)
  366. m.Combo("/:id", reqToken()).Patch(bind(api.EditIssueCommentOption{}), repo.EditIssueComment).
  367. Delete(repo.DeleteIssueComment)
  368. })
  369. m.Group("/labels", func() {
  370. m.Combo("").Get(repo.ListIssueLabels).
  371. Post(reqToken(), bind(api.IssueLabelsOption{}), repo.AddIssueLabels).
  372. Put(reqToken(), bind(api.IssueLabelsOption{}), repo.ReplaceIssueLabels).
  373. Delete(reqToken(), repo.ClearIssueLabels)
  374. m.Delete("/:id", reqToken(), repo.DeleteIssueLabel)
  375. })
  376. })
  377. }, mustEnableIssues)
  378. m.Group("/labels", func() {
  379. m.Combo("").Get(repo.ListLabels).
  380. Post(reqToken(), bind(api.CreateLabelOption{}), repo.CreateLabel)
  381. m.Combo("/:id").Get(repo.GetLabel).
  382. Patch(reqToken(), bind(api.EditLabelOption{}), repo.EditLabel).
  383. Delete(reqToken(), repo.DeleteLabel)
  384. })
  385. m.Group("/milestones", func() {
  386. m.Combo("").Get(repo.ListMilestones).
  387. Post(reqToken(), reqRepoWriter(), bind(api.CreateMilestoneOption{}), repo.CreateMilestone)
  388. m.Combo("/:id").Get(repo.GetMilestone).
  389. Patch(reqToken(), reqRepoWriter(), bind(api.EditMilestoneOption{}), repo.EditMilestone).
  390. Delete(reqToken(), reqRepoWriter(), repo.DeleteMilestone)
  391. })
  392. m.Get("/stargazers", repo.ListStargazers)
  393. m.Get("/subscribers", repo.ListSubscribers)
  394. m.Group("/subscription", func() {
  395. m.Get("", user.IsWatching)
  396. m.Put("", reqToken(), user.Watch)
  397. m.Delete("", reqToken(), user.Unwatch)
  398. })
  399. m.Group("/releases", func() {
  400. m.Combo("").Get(repo.ListReleases).
  401. Post(reqToken(), reqRepoWriter(), bind(api.CreateReleaseOption{}), repo.CreateRelease)
  402. m.Combo("/:id").Get(repo.GetRelease).
  403. Patch(reqToken(), reqRepoWriter(), bind(api.EditReleaseOption{}), repo.EditRelease).
  404. Delete(reqToken(), reqRepoWriter(), repo.DeleteRelease)
  405. })
  406. m.Post("/mirror-sync", reqToken(), reqRepoWriter(), repo.MirrorSync)
  407. m.Get("/editorconfig/:filename", context.RepoRef(), repo.GetEditorconfig)
  408. m.Group("/pulls", func() {
  409. m.Combo("").Get(bind(api.ListPullRequestsOptions{}), repo.ListPullRequests).
  410. Post(reqToken(), reqRepoWriter(), bind(api.CreatePullRequestOption{}), repo.CreatePullRequest)
  411. m.Group("/:index", func() {
  412. m.Combo("").Get(repo.GetPullRequest).
  413. Patch(reqToken(), reqRepoWriter(), bind(api.EditPullRequestOption{}), repo.EditPullRequest)
  414. m.Combo("/merge").Get(repo.IsPullRequestMerged).
  415. Post(reqToken(), reqRepoWriter(), repo.MergePullRequest)
  416. })
  417. }, mustAllowPulls, context.ReferencesGitRepo())
  418. m.Group("/statuses", func() {
  419. m.Combo("/:sha").Get(repo.GetCommitStatuses).
  420. Post(reqToken(), reqRepoWriter(), bind(api.CreateStatusOption{}), repo.NewCommitStatus)
  421. })
  422. m.Group("/commits/:ref", func() {
  423. m.Get("/status", repo.GetCombinedCommitStatus)
  424. m.Get("/statuses", repo.GetCommitStatuses)
  425. })
  426. }, repoAssignment())
  427. })
  428. // Organizations
  429. m.Get("/user/orgs", reqToken(), org.ListMyOrgs)
  430. m.Get("/users/:username/orgs", org.ListUserOrgs)
  431. m.Group("/orgs/:orgname", func() {
  432. m.Get("/repos", user.ListOrgRepos)
  433. m.Combo("").Get(org.Get).
  434. Patch(reqToken(), reqOrgOwnership(), bind(api.EditOrgOption{}), org.Edit)
  435. m.Group("/members", func() {
  436. m.Get("", org.ListMembers)
  437. m.Combo("/:username").Get(org.IsMember).
  438. Delete(reqToken(), reqOrgOwnership(), org.DeleteMember)
  439. })
  440. m.Group("/public_members", func() {
  441. m.Get("", org.ListPublicMembers)
  442. m.Combo("/:username").Get(org.IsPublicMember).
  443. Put(reqToken(), reqOrgMembership(), org.PublicizeMember).
  444. Delete(reqToken(), reqOrgMembership(), org.ConcealMember)
  445. })
  446. m.Combo("/teams", reqToken(), reqOrgMembership()).Get(org.ListTeams).
  447. Post(bind(api.CreateTeamOption{}), org.CreateTeam)
  448. m.Group("/hooks", func() {
  449. m.Combo("").Get(org.ListHooks).
  450. Post(bind(api.CreateHookOption{}), org.CreateHook)
  451. m.Combo("/:id").Get(org.GetHook).
  452. Patch(reqOrgOwnership(), bind(api.EditHookOption{}), org.EditHook).
  453. Delete(reqOrgOwnership(), org.DeleteHook)
  454. }, reqToken(), reqOrgMembership())
  455. }, orgAssignment(true))
  456. m.Group("/teams/:teamid", func() {
  457. m.Combo("").Get(org.GetTeam).
  458. Patch(reqOrgOwnership(), bind(api.EditTeamOption{}), org.EditTeam).
  459. Delete(reqOrgOwnership(), org.DeleteTeam)
  460. m.Group("/members", func() {
  461. m.Get("", org.GetTeamMembers)
  462. m.Combo("/:username").
  463. Put(reqOrgOwnership(), org.AddTeamMember).
  464. Delete(reqOrgOwnership(), org.RemoveTeamMember)
  465. })
  466. m.Group("/repos", func() {
  467. m.Get("", org.GetTeamRepos)
  468. m.Combo("/:orgname/:reponame").
  469. Put(org.AddTeamRepository).
  470. Delete(org.RemoveTeamRepository)
  471. })
  472. }, orgAssignment(false, true), reqToken(), reqOrgMembership())
  473. m.Any("/*", func(ctx *context.Context) {
  474. ctx.Error(404)
  475. })
  476. m.Group("/admin", func() {
  477. m.Group("/users", func() {
  478. m.Post("", bind(api.CreateUserOption{}), admin.CreateUser)
  479. m.Group("/:username", func() {
  480. m.Combo("").Patch(bind(api.EditUserOption{}), admin.EditUser).
  481. Delete(admin.DeleteUser)
  482. m.Post("/keys", bind(api.CreateKeyOption{}), admin.CreatePublicKey)
  483. m.Post("/orgs", bind(api.CreateOrgOption{}), admin.CreateOrg)
  484. m.Post("/repos", bind(api.CreateRepoOption{}), admin.CreateRepo)
  485. })
  486. })
  487. }, reqAdmin())
  488. }, context.APIContexter())
  489. }