|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.sitebricks.headless.Reply<E>
public abstract class Reply<E>
Reply to a (headless) web request.
| Field Summary | |
|---|---|
static Reply<?> |
NO_REPLY
|
static String |
NO_REPLY_ATTR
|
| Constructor Summary | |
|---|---|
Reply()
|
|
| Method Summary | ||
|---|---|---|
abstract Reply<E> |
as(Class<? extends Transport> transport)
Directs sitebricks to use the given Guice key as a transport to marshall the provided entity to the client. |
|
abstract Reply<E> |
as(com.google.inject.Key<? extends Transport> transport)
Same as as(Class). |
|
abstract Reply<E> |
error()
Perform a 500 general error response. |
|
abstract Reply<E> |
forbidden()
Perform a 403 resource forbidden error response. |
|
abstract Reply<E> |
headers(Map<String,String> headers)
A Map of headers to set directly on the response. |
|
abstract Reply<E> |
noContent()
Perform a 204 no content response. |
|
abstract Reply<E> |
notFound()
Perform a 404 not found reply. |
|
abstract Reply<E> |
ok()
Perform a 200 OK response with no body. |
|
abstract Reply<E> |
redirect(String uri)
Perform a 302 redirect to the given uri (moved temporarily). |
|
static
|
saying()
Convenience method to make a reply without any entity or body. |
|
abstract Reply<E> |
seeOther(String uri)
Perform a 301 redirect (moved permanently) to the given uri. |
|
abstract Reply<E> |
seeOther(String uri,
int statusCode)
Perform a custom redirect to the given uri. |
|
abstract Reply<E> |
status(int code)
Set a custom status code (call this last, it will be overridden if other response code directives are called afterward). |
|
abstract Reply<E> |
template(Class<?> templateKey)
Render template associated with the given class. |
|
abstract Reply<E> |
type(String mediaType)
The media type of the response data to send to the client. |
|
abstract Reply<E> |
unauthorized()
Perform a 401 not authorized reply. |
|
static
|
with(E entity)
Returns a reply with an entity that is sent back to the client via the specified transport. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final Reply<?> NO_REPLY
public static final String NO_REPLY_ATTR
| Constructor Detail |
|---|
public Reply()
| Method Detail |
|---|
public abstract Reply<E> seeOther(String uri)
public abstract Reply<E> seeOther(String uri,
int statusCode)
public abstract Reply<E> type(String mediaType)
"application/json" for JSON responses.
public abstract Reply<E> headers(Map<String,String> headers)
public abstract Reply<E> notFound()
public abstract Reply<E> unauthorized()
public abstract Reply<E> as(Class<? extends Transport> transport)
return Reply.with(new Person(..)).as(Xml.class);
Will marhall the given Person object into XML using the Guice Key bound to [Xml.class] (by default this is an XStream based XML transport).
public abstract Reply<E> as(com.google.inject.Key<? extends Transport> transport)
as(Class).
public abstract Reply<E> redirect(String uri)
public abstract Reply<E> forbidden()
public abstract Reply<E> noContent()
public abstract Reply<E> error()
public abstract Reply<E> template(Class<?> templateKey)
The entity passed into with() is used as the template's context during render.
public abstract Reply<E> status(int code)
public abstract Reply<E> ok()
public static <E> Reply<E> saying()
return Reply.saying().redirect("/other");
public static <E> Reply<E> with(E entity)
entity - An entity to send back for which a valid transport exists (see
as(Class)).
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||