-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClientError.go
56 lines (46 loc) · 1.51 KB
/
ClientError.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package response
import (
"github.com/aws/aws-lambda-go/events"
)
const (
//BadRequestRequired error code for required fields
BadRequestRequired = "REQUIRED"
//BadRequestDuplicate error code for duplicate fields
BadRequestDuplicate = "DUPLICATE"
//BadRequestInvalid error code for invalid fields
BadRequestInvalid = "INVALID"
//BadRequestNoMatch error code for no matching found
BadRequestNoMatch = "NO_MATCH"
)
//BadRequest return 400 code
func BadRequest() (events.APIGatewayProxyResponse, error) {
return Custom(400, "Bad Request", nil)
}
//BadRequestWithCode return 400 code
func BadRequestWithCode(codes map[string]string) (events.APIGatewayProxyResponse, error) {
return CustomJSON(400, codes, nil)
}
//Unauthorized return 401 code
func Unauthorized() (events.APIGatewayProxyResponse, error) {
return Custom(401, "Unauthorized", nil)
}
//Forbidden return 403 code
func Forbidden() (events.APIGatewayProxyResponse, error) {
return Custom(403, "Forbidden", nil)
}
//NotFound return 404 code
func NotFound() (events.APIGatewayProxyResponse, error) {
return Custom(404, "Resource Not Found", nil)
}
//MethodNotAllowed return 405 code
func MethodNotAllowed() (events.APIGatewayProxyResponse, error) {
return Custom(405, "Method Not Allowed", nil)
}
//PreconditionFailed return 412 code
func PreconditionFailed() (events.APIGatewayProxyResponse, error) {
return Custom(412, "Precondition Failed", nil)
}
//Locked return 423 code
func Locked() (events.APIGatewayProxyResponse, error) {
return Custom(423, "Locked", nil)
}