Package ninja
Class Results
- java.lang.Object
-
- ninja.Results
-
public class Results extends Object
Convenience methods for the generation of Results.generates a results and sets it to forbidden. A range of shortcuts are available from here.- Author:
- rbauer
-
-
Constructor Summary
Constructors Constructor Description Results()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static AsyncResultasync()static ResultbadRequest()static ResultcontentType(String contentType)static Resultcreated(Optional<String> url)static Resultforbidden()static Resulthtml()static ResultinternalServerError()static Resultjson()static Resultjsonp()static ResultnoContent()static ResultnotFound()static Resultok()static Resultredirect(String url)A redirect that uses 303 see other.static ResultredirectTemporary(String url)A redirect that uses 307 see other.static Resultstatus(int statusCode)static Resulttext()static ResultTODO()static Resultunauthorized()static ResultwebSocketContinue()Instructs ninja (and the http container) that it is okay to continue with the websocket handshake.static Resultxml()
-
-
-
Method Detail
-
status
public static Result status(int statusCode)
-
ok
public static Result ok()
-
notFound
public static Result notFound()
-
forbidden
public static Result forbidden()
-
unauthorized
public static Result unauthorized()
-
badRequest
public static Result badRequest()
-
noContent
public static Result noContent()
-
internalServerError
public static Result internalServerError()
-
redirect
public static Result redirect(String url)
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 theNoHttpBodythat is set as renderable of the Result.- Parameters:
url- The url used as redirect target.- Returns:
- A nicely configured result with status code 303 and the url set as Location header. Renders no Http body by default.
-
redirectTemporary
public static Result redirectTemporary(String url)
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 theNoHttpBodythat is set as renderable of the Result.- Parameters:
url- The url used as redirect target.- Returns:
- A nicely configured result with status code 307 and the url set as Location header. Renders no Http body by default.
-
html
public static Result html()
-
text
public static Result text()
-
json
public static Result json()
-
jsonp
public static Result jsonp()
-
xml
public static Result xml()
-
TODO
public static Result TODO()
-
webSocketContinue
public static Result webSocketContinue()
Instructs ninja (and the http container) that it is okay to continue with the websocket handshake. This sets the HTTP status code to101 Switching Protocols. 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).
-
async
public static AsyncResult async()
-
-