document repository API methods

This commit is contained in:
Brad Rydzewski 2015-06-23 11:35:21 -07:00
parent e728349265
commit 3b63d83d03
3 changed files with 103 additions and 1 deletions

View file

@ -78,6 +78,7 @@ func main() {
api.Use(server.SetSession(session))
api.Use(server.SetUser(session))
api.Use(server.SetRunner(&runner_))
api.OPTIONS("/*path", func(c *gin.Context) {})
user := api.Group("/user")
{

View file

@ -46,6 +46,98 @@ paths:
description: The repository.
schema:
$ref: "#/definitions/Repo"
patch:
parameters:
- name: owner
in: path
type: string
- name: name
in: path
type: string
description: Updates the repository.
security:
- accessToken: []
responses:
"200":
description: The updated repository.
schema:
$ref: "#/definitions/Repo"
delete:
parameters:
- name: owner
in: path
type: string
- name: name
in: path
type: string
description: Deletes the repository.
security:
- accessToken: []
/repos/{owner}/{name}/watch:
post:
parameters:
- name: owner
in: path
type: string
- name: name
in: path
type: string
description: Watches the named repository.
security:
- accessToken: []
/repos/{owner}/{name}/unwatch:
delete:
parameters:
- name: owner
in: path
type: string
- name: name
in: path
type: string
description: Unwatches the repository.
security:
- accessToken: []
/repos/{owner}/{name}/builds:
get:
parameters:
- name: owner
in: path
type: string
- name: name
in: path
type: string
description: Returns recent builds for the repository based on name.
security:
- accessToken: []
responses:
"200":
description: The recent builds.
schema:
type: array
items:
$ref: "#/definitions/Build"
/repos/{owner}/{name}/builds/{number}:
get:
parameters:
- name: owner
in: path
type: string
- name: name
in: path
type: string
- name: number
in: path
type: integer
description: Returns the repository build by number.
security:
- accessToken: []
responses:
"200":
description: The build.
schema:
$ref: "#/definitions/Build"
/user:
get:
description: Returns the currently authenticated user.

View file

@ -321,6 +321,15 @@ func SetHeaders() gin.HandlerFunc {
c.Writer.Header().Add("Strict-Transport-Security", "max-age=31536000")
}
if c.Request.Method == "OPTIONS" {
c.Writer.Header().Set("Access-Control-Allow-Methods", "GET,POST,PUT,PATCH,DELETE,OPTIONS")
c.Writer.Header().Set("Access-Control-Allow-Headers", "Authorization")
c.Writer.Header().Set("Allow", "HEAD,GET,POST,PUT,PATCH,DELETE,OPTIONS")
c.Writer.Header().Set("Content-Type", "application/json")
c.Writer.WriteHeader(200)
return
}
c.Next()
}
}