/** * Instructs ninja (and the http container) that it is okay to continue with * the websocket handshake. This sets the HTTP status code to * <code>101 Switching Protocols</code>. Do not include any result via * a render() as writing it out will not be possible if you intend on * switching protocols (e.g. upgrade to a websocket). */ public static Result webSocketContinue() { return status(Result.SC_101_SWITCHING_PROTOCOLS); }
public static Result internalServerError() { return status(Result.SC_500_INTERNAL_SERVER_ERROR); }
public static Result notFound() { return status(Result.SC_404_NOT_FOUND); }
public static Result badRequest() { return status(Result.SC_400_BAD_REQUEST); }
public static Result ok() { return status(Result.SC_200_OK); }
public static Result forbidden() { return status(Result.SC_403_FORBIDDEN); }
public static Result unauthorized() { return status(Result.SC_401_UNAUTHORIZED); }
public static Result html() { Result result = status(Result.SC_200_OK); result.contentType(Result.TEXT_HTML); return result; }
public static Result text() { Result result = status(Result.SC_200_OK); result.contentType(Result.TEXT_PLAIN); return result; }
public static Result TODO() { Result result = status(Result.SC_501_NOT_IMPLEMENTED); result.contentType(Result.APPLICATION_JSON); return result; }
public static Result created(Optional<String> url) { Result result = status(Result.SC_201_CREATED); if (url.isPresent()) { result.addHeader(Result.LOCATION, url.get()); } return result; }
public static Result contentType(String contentType) { Result result = status(Result.SC_200_OK); result.contentType(contentType); return result; }
public static Result json() { Result result = status(Result.SC_200_OK).json(); return result; }
public static Result xml() { Result result = status(Result.SC_200_OK).xml(); return result; }
public static Result noContent() { return status(Result.SC_204_NO_CONTENT) .render(Result.NO_HTTP_BODY); }
public static Result jsonp() { Result result = status(Result.SC_200_OK).jsonp(); return result; }
/** * A redirect that uses 303 see other. * * The redirect does NOT need a template and does NOT * render a text in the Http body by default. * * If you wish to do so please * remove the {@link NoHttpBody} that is set as renderable of * the Result. * * @param url * The url used as redirect target. * @return A nicely configured result with status code 303 and the url set * as Location header. Renders no Http body by default. */ public static Result redirect(String url) { Result result = status(Result.SC_303_SEE_OTHER); result.addHeader(Result.LOCATION, url); result.render(Result.NO_HTTP_BODY); return result; }
/** * A redirect that uses 307 see other. * * The redirect does NOT need a template and does NOT * render a text in the Http body by default. * * If you wish to do so please * remove the {@link NoHttpBody} that is set as renderable of * the Result. * * @param url * The url used as redirect target. * @return A nicely configured result with status code 307 and the url set * as Location header. Renders no Http body by default. */ public static Result redirectTemporary(String url) { Result result = status(Result.SC_307_TEMPORARY_REDIRECT); result.addHeader(Result.LOCATION, url); result.render(Result.NO_HTTP_BODY); return result; }