Skip to content

Commit d033236

Browse files
committed
[api] return 202 on successful CSR submit
1 parent 8b5d605 commit d033236

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

api/docs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ const docTemplate = `{
4646
}
4747
],
4848
"responses": {
49-
"200": {
50-
"description": "OK",
49+
"202": {
50+
"description": "Accepted",
5151
"schema": {
5252
"$ref": "#/definitions/ca.PostCSRResponse"
5353
}

api/swagger.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
}
4444
],
4545
"responses": {
46-
"200": {
47-
"description": "OK",
46+
"202": {
47+
"description": "Accepted",
4848
"schema": {
4949
"$ref": "#/definitions/ca.PostCSRResponse"
5050
}

api/swagger.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ paths:
9898
produces:
9999
- application/json
100100
responses:
101-
"200":
102-
description: OK
101+
"202":
102+
description: Accepted
103103
schema:
104104
$ref: '#/definitions/ca.PostCSRResponse'
105105
"400":

internal/api/csr.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type csrHandler struct {
2222
// @Accept json
2323
// @Produce json
2424
// @Param request body ca.PostCSRRequest true "Request"
25-
// @Success 200 {object} ca.PostCSRResponse
25+
// @Success 202 {object} ca.PostCSRResponse
2626
// @Failure 400 {object} http.JSONErrorResponse
2727
// @Failure 500 {object} http.JSONErrorResponse
2828
// @Router /csr [post]
@@ -39,12 +39,14 @@ func (c *csrHandler) submit(ctx *fiber.Ctx) error {
3939
return err
4040
}
4141

42-
return ctx.JSON(ca.PostCSRResponse{
43-
RequestID: res.ID(),
44-
Status: res.Status(),
45-
Message: res.Status().Description(),
46-
Certificate: res.Certificate(),
47-
})
42+
return ctx.
43+
Status(fiber.StatusAccepted).
44+
JSON(ca.PostCSRResponse{
45+
RequestID: res.ID(),
46+
Status: res.Status(),
47+
Message: res.Status().Description(),
48+
Certificate: res.Certificate(),
49+
})
4850
}
4951

5052
// @Summary Get CSR Status

0 commit comments

Comments
 (0)