summaryrefslogtreecommitdiff
path: root/errors
diff options
context:
space:
mode:
authorDavid Calavera <david.calavera@gmail.com>2015-09-15 19:01:49 -0400
committerDavid Calavera <david.calavera@gmail.com>2015-09-21 14:27:06 -0400
commit0fea04d27ee91d7b57e0a77b110db1c861768c74 (patch)
tree5875108f34fb0a495da3bf0d651c8085010d2d2d /errors
parent72eb75a06c8533ada2062454de4981c46db63fb7 (diff)
downloaddocker-0fea04d27ee91d7b57e0a77b110db1c861768c74.tar.gz
Organize server pre-func logic in middlewares.
It defines global middlewares for every request. This makes the server slightly more composable. Signed-off-by: David Calavera <david.calavera@gmail.com>
Diffstat (limited to 'errors')
-rw-r--r--errors/server.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/errors/server.go b/errors/server.go
new file mode 100644
index 0000000000..9dfcc02b50
--- /dev/null
+++ b/errors/server.go
@@ -0,0 +1,27 @@
+package errors
+
+import (
+ "net/http"
+
+ "github.com/docker/distribution/registry/api/errcode"
+)
+
+var (
+ // ErrorCodeNewerClientVersion is generated when a request from a client
+ // specifies a higher version than the server supports.
+ ErrorCodeNewerClientVersion = errcode.Register(errGroup, errcode.ErrorDescriptor{
+ Value: "NEWERCLIENTVERSION",
+ Message: "client is newer than server (client API version: %s, server API version: %s)",
+ Description: "The client version is higher than the server version",
+ HTTPStatusCode: http.StatusBadRequest,
+ })
+
+ // ErrorCodeOldClientVersion is generated when a request from a client
+ // specifies a version lower than the minimum version supported by the server.
+ ErrorCodeOldClientVersion = errcode.Register(errGroup, errcode.ErrorDescriptor{
+ Value: "OLDCLIENTVERSION",
+ Message: "client version %s is too old. Minimum supported API version is %s, please upgrade your client to a newer version",
+ Description: "The client version is too old for the server",
+ HTTPStatusCode: http.StatusBadRequest,
+ })
+)