diff --git a/src/main/java/io/sinistral/proteus/server/ServerResponse.java b/src/main/java/io/sinistral/proteus/server/ServerResponse.java index e1a3b61..f1e451a 100644 --- a/src/main/java/io/sinistral/proteus/server/ServerResponse.java +++ b/src/main/java/io/sinistral/proteus/server/ServerResponse.java @@ -130,7 +130,7 @@ public void setStatus(int status) * @param contentType * the contentType to set */ - public void setContentType(String contentType) + protected void setContentType(String contentType) { this.contentType = contentType; @@ -281,6 +281,13 @@ public ServerResponse redirectPermanently(String location) this.status = StatusCodes.MOVED_PERMANENTLY;; return this; } + + public ServerResponse found() + { + this.status = StatusCodes.FOUND; + return this; + } + public ServerResponse accepted() { @@ -296,13 +303,12 @@ public ServerResponse badRequest() public ServerResponse badRequest(Throwable t) { - this.status = StatusCodes.BAD_REQUEST; this.throwable = t; - return this; + return this.badRequest(); } public ServerResponse badRequest(String message) { - return this.badRequest(new Throwable(message)); + return this.errorMessage(message).badRequest(); } public ServerResponse internalServerError() @@ -313,14 +319,13 @@ public ServerResponse internalServerError() public ServerResponse internalServerError(Throwable t) { - this.status = StatusCodes.INTERNAL_SERVER_ERROR; this.throwable = t; - return this; + return this.internalServerError(); } public ServerResponse internalServerError(String message) { - return this.internalServerError(new Throwable(message)); + return this.errorMessage(message).internalServerError(); } public ServerResponse created() @@ -337,14 +342,13 @@ public ServerResponse notFound() public ServerResponse notFound(Throwable t) { - this.status = StatusCodes.NOT_FOUND; this.throwable = t; - return this; + return this.notFound(); } public ServerResponse notFound(String message) { - return this.notFound(new Throwable(message)); + return this.errorMessage(message).notFound(); } @@ -355,41 +359,74 @@ public ServerResponse forbidden() } public ServerResponse forbidden(Throwable t) - { - this.status = StatusCodes.FORBIDDEN; + { this.throwable = t; - return this; + return this.forbidden(); } public ServerResponse forbidden(String message) { - return this.forbidden(new Throwable(message)); + return this.errorMessage(message).forbidden(); } - - public ServerResponse found() + public ServerResponse noContent() { - this.status = StatusCodes.FOUND; + this.status = StatusCodes.NO_CONTENT; return this; } + + public ServerResponse noContent(Throwable t) + { + this.throwable = t; + return this.noContent(); + } - public ServerResponse noContent() + + public ServerResponse noContent(String message) + { + return this.errorMessage(message).noContent(); + } + + public ServerResponse serviceUnavailable() { - this.status = StatusCodes.NO_CONTENT; + this.status = StatusCodes.SERVICE_UNAVAILABLE; return this; } - public ServerResponse noContent(Throwable t) + public ServerResponse serviceUnavailable(Throwable t) { - this.status = StatusCodes.NO_CONTENT; this.throwable = t; + return this.serviceUnavailable(); + } + + + public ServerResponse serviceUnavailable(String message) + { + return this.errorMessage(message).serviceUnavailable(); + } + + public ServerResponse unauthorized() + { + this.status = StatusCodes.UNAUTHORIZED; return this; } + + public ServerResponse unauthorized(Throwable t) + { + this.throwable = t; + return this.unauthorized(); + } - public ServerResponse noContent(String message) + public ServerResponse unauthorized(String message) + { + return this.errorMessage(message).unauthorized(); + } + + public ServerResponse errorMessage(String message) { - return this.noContent(new Throwable(message)); + this.throwable = new Throwable(message); + return this; } public ServerResponse withIoCallback(IoCallback ioCallback)