summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/context/api.go34
1 files changed, 31 insertions, 3 deletions
diff --git a/modules/context/api.go b/modules/context/api.go
index 0d279d93b2..2068285c7a 100644
--- a/modules/context/api.go
+++ b/modules/context/api.go
@@ -23,6 +23,34 @@ type APIContext struct {
Org *APIOrganization
}
+// APIError is error format response
+// swagger:response error
+type APIError struct {
+ Message string `json:"message"`
+ URL string `json:"url"`
+}
+
+// APIValidationError is error format response related to input validation
+// swagger:response validationError
+type APIValidationError struct {
+ Message string `json:"message"`
+ URL string `json:"url"`
+}
+
+//APIEmpty is a empty response
+// swagger:response empty
+type APIEmpty struct{}
+
+//APIForbiddenError is a forbidden error response
+// swagger:response forbidden
+type APIForbiddenError struct {
+ APIError
+}
+
+//APINotFound is a not found empty response
+// swagger:response notFound
+type APINotFound struct{}
+
// Error responses error message to client with given message.
// If status is 500, also it prints error to log.
func (ctx *APIContext) Error(status int, title string, obj interface{}) {
@@ -37,9 +65,9 @@ func (ctx *APIContext) Error(status int, title string, obj interface{}) {
log.Error(4, "%s: %s", title, message)
}
- ctx.JSON(status, map[string]string{
- "message": message,
- "url": base.DocURL,
+ ctx.JSON(status, APIError{
+ Message: message,
+ URL: base.DocURL,
})
}