Spaces:
Paused
Paused
File size: 2,340 Bytes
83a59ca | 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 57 58 59 60 61 62 | package responses
type response struct {
Status string `json:"status" example:"success"`
Message string `json:"message" example:"Request handled successfully"`
}
// InternalServerError is the response with status code is 500
type InternalServerError struct {
Status string `json:"status" example:"error"`
Message string `json:"message" example:"We ran into an internal error while handling the request."`
}
// NotFound is the response with status code is 404
type NotFound struct {
Status string `json:"status" example:"error"`
Message string `json:"message" example:"cannot find message with ID [32343a19-da5e-4b1b-a767-3298a73703ca]"`
}
// BadRequest is the response with status code is 400
type BadRequest struct {
Status string `json:"status" example:"error"`
Message string `json:"message" example:"The request isn't properly formed"`
Data string `json:"data" example:"The request body is not a valid JSON string"`
}
// UnprocessableEntity is the response with status code is 422
type UnprocessableEntity struct {
Status string `json:"status" example:"error"`
Message string `json:"message" example:"validation errors while handling request"`
Data map[string][]string `json:"data"`
}
// Unauthorized is the response with status code is 403
type Unauthorized struct {
Status string `json:"status" example:"error"`
Message string `json:"message" example:"You are not authorized to carry out this request."`
Data string `json:"data" example:"Make sure your API key is set in the [X-API-Key] header in the request"`
}
// PaymentRequired is the response with status code is 402
type PaymentRequired struct {
Status string `json:"status" example:"error"`
Message string `json:"message" example:"You have reached the maximum number of allowed resources. Please upgrade your plan."`
}
// NoContent is the response when status code is 204
type NoContent struct {
Status string `json:"status" example:"success"`
Message string `json:"message" example:"action performed successfully"`
}
// Ok is the response with status code is 200
type Ok[T any] struct {
Status string `json:"status" example:"success"`
Message string `json:"message" example:"Request handled successfully"`
Data T `json:"data"`
}
// OkString returns a string response
type OkString Ok[string]
|