Skip to content

Commit

Permalink
Merge pull request #28 from fsy2001/put
Browse files Browse the repository at this point in the history
change: PUT route path suffix
  • Loading branch information
JingYiJun authored Aug 4, 2024
2 parents b8fa7bc + 8111025 commit fb010e5
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion apis/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ func register(c *fiber.Ctx, email, password string, batch bool) error {
// @Accept json
// @Produce json
// @Router /register [put]
// @Router /register [patch]
// @Router /register/_webvpn [patch]
// @Param json body RegisterRequest true "json"
// @Success 200 {object} TokenResponse
// @Failure 400 {object} common.MessageResponse "验证码错误"
Expand Down
6 changes: 3 additions & 3 deletions apis/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func RegisterRoutes(app *fiber.App) {
routes.Get("/verify/apikey", VerifyWithApikey)
routes.Post("/register", Register)
routes.Put("/register", ChangePassword)
routes.Patch("/register", ChangePassword)
routes.Patch("/register/_webvpn", ChangePassword)
routes.Delete("/users/me", DeleteUser)
routes.Delete("/users/:id", DeleteUserByID)

Expand All @@ -53,7 +53,7 @@ func RegisterRoutes(app *fiber.App) {
routes.Get("/users/:id", GetUserByID)
routes.Get("/users", ListUsers)
routes.Put("/users/:id", ModifyUser)
routes.Patch("/users/:id<int>/_modify", ModifyUser)
routes.Patch("/users/:id<int>/_webvpn", ModifyUser)

// shamir
routes.Get("/shamir/status", GetShamirStatus)
Expand All @@ -63,7 +63,7 @@ func RegisterRoutes(app *fiber.App) {
routes.Post("/shamir/key", UploadPublicKey)
routes.Post("/shamir/update", UpdateShamir)
routes.Put("/shamir/refresh", RefreshShamir)
routes.Patch("/shamir/refresh", RefreshShamir)
routes.Patch("/shamir/refresh/_webvpn", RefreshShamir)
routes.Post("/shamir/decrypt", UploadUserShares)
routes.Get("/shamir/decrypt/:id", GetDecryptedUserEmail)
routes.Get("/shamir/decrypt/status/:id", GetDecryptStatusbyUserID)
Expand Down
2 changes: 1 addition & 1 deletion apis/shamir.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ func UpdateShamir(c *fiber.Ctx) error {
// @Summary trigger for refresh uploaded shares
// @Tags shamir
// @Router /shamir/refresh [put]
// @Router /shamir/refresh [patch]
// @Router /shamir/refresh/_webvpn [patch]
// @Success 204
// @Failure 403 {object} common.MessageResponse "非管理员"
// @failure 500 {object} common.MessageResponse
Expand Down
2 changes: 1 addition & 1 deletion apis/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func ListAdmin(c *fiber.Ctx) error {
// @Tags user
// @Produce json
// @Router /users/{user_id} [put]
// @Router /users/{user_id}/_modify [patch]
// @Router /users/{user_id}/_webvpn [patch]
// @Param user_id path int true "UserID"
// @Success 201 {object} User
// @Failure 403 {object} common.MessageResponse "不是管理员"
Expand Down
10 changes: 7 additions & 3 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ const docTemplate = `{
}
}
}
},
}
},
"/register/_webvpn": {
"patch": {
"description": "reset password, reset jwt credential",
"consumes": [
Expand Down Expand Up @@ -753,7 +755,9 @@ const docTemplate = `{
}
}
}
},
}
},
"/shamir/refresh/_webvpn": {
"patch": {
"tags": [
"shamir"
Expand Down Expand Up @@ -1239,7 +1243,7 @@ const docTemplate = `{
}
}
},
"/users/{user_id}/_modify": {
"/users/{user_id}/_webvpn": {
"patch": {
"description": "modify user, owner or admin",
"produces": [
Expand Down
10 changes: 7 additions & 3 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@
}
}
}
},
}
},
"/register/_webvpn": {
"patch": {
"description": "reset password, reset jwt credential",
"consumes": [
Expand Down Expand Up @@ -747,7 +749,9 @@
}
}
}
},
}
},
"/shamir/refresh/_webvpn": {
"patch": {
"tags": [
"shamir"
Expand Down Expand Up @@ -1233,7 +1237,7 @@
}
}
},
"/users/{user_id}/_modify": {
"/users/{user_id}/_webvpn": {
"patch": {
"description": "modify user, owner or admin",
"produces": [
Expand Down
34 changes: 18 additions & 16 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,10 @@ paths:
tags:
- token
/register:
patch:
post:
consumes:
- application/json
description: reset password, reset jwt credential
description: register with email, password and verification code
parameters:
- description: json
in: body
Expand All @@ -552,25 +552,25 @@ paths:
produces:
- application/json
responses:
"200":
description: OK
"201":
description: Created
schema:
$ref: '#/definitions/apis.TokenResponse'
"400":
description: 验证码错误
description: 验证码错误、用户已注册
schema:
$ref: '#/definitions/common.MessageResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/common.MessageResponse'
summary: reset password
summary: register
tags:
- account
post:
put:
consumes:
- application/json
description: register with email, password and verification code
description: reset password, reset jwt credential
parameters:
- description: json
in: body
Expand All @@ -581,22 +581,23 @@ paths:
produces:
- application/json
responses:
"201":
description: Created
"200":
description: OK
schema:
$ref: '#/definitions/apis.TokenResponse'
"400":
description: 验证码错误、用户已注册
description: 验证码错误
schema:
$ref: '#/definitions/common.MessageResponse'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/common.MessageResponse'
summary: register
summary: reset password
tags:
- account
put:
/register/_webvpn:
patch:
consumes:
- application/json
description: reset password, reset jwt credential
Expand Down Expand Up @@ -891,7 +892,7 @@ paths:
tags:
- shamir
/shamir/refresh:
patch:
put:
responses:
"204":
description: No Content
Expand All @@ -906,7 +907,8 @@ paths:
summary: trigger for refresh uploaded shares
tags:
- shamir
put:
/shamir/refresh/_webvpn:
patch:
responses:
"204":
description: No Content
Expand Down Expand Up @@ -1117,7 +1119,7 @@ paths:
summary: modify user
tags:
- user
/users/{user_id}/_modify:
/users/{user_id}/_webvpn:
patch:
description: modify user, owner or admin
parameters:
Expand Down

0 comments on commit fb010e5

Please sign in to comment.