Request.Forwarding
Constructor and Description |
---|
Forwarding(Request request)
Creates a new
Request.Forwarding request. |
Modifier and Type | Method and Description |
---|---|
List<MediaType> |
accept() |
Optional<MediaType> |
accepts(List<MediaType> types)
Check if the given types are acceptable, returning the best match when true, or else
Optional.empty.
|
Optional<MediaType> |
accepts(MediaType... types)
Check if the given types are acceptable, returning the best match when true, or else
Optional.empty.
|
Optional<MediaType> |
accepts(String... types)
Check if the given types are acceptable, returning the best match when true, or else
Optional.empty.
|
Map<String,Object> |
attributes()
A read only version of the current locals.
|
Mutant |
body()
HTTP body.
|
Charset |
charset()
The charset defined in the request body.
|
Optional<Cookie> |
cookie(String name)
Get a cookie with the given name (if present).
|
List<Cookie> |
cookies() |
<T> Optional<T> |
get(String name)
Get a request local attribute.
|
Mutant |
header(String name)
Get a HTTP header.
|
Map<String,Mutant> |
headers() |
String |
hostname()
The fully qualified name of the client or the last proxy that sent the request.
|
Optional<Session> |
ifSession() |
String |
ip() |
boolean |
is(List<MediaType> types)
True, if request accept any of the given types.
|
boolean |
is(MediaType... types)
True, if request accept any of the given types.
|
boolean |
is(String... types)
True, if request accept any of the given types.
|
boolean |
isSet(String name) |
long |
length() |
Locale |
locale()
Get the content of the
Accept-Language header. |
String |
method() |
Mutant |
param(String name)
Get a HTTP request parameter under the given name.
|
Mutant |
params()
Get all the available parameters.
|
String |
path()
Given:
|
int |
port() |
String |
protocol() |
<T> T |
require(Class<T> type)
Ask Guice for the given type.
|
<T> T |
require(com.google.inject.Key<T> key)
Ask Guice for the given type.
|
<T> T |
require(com.google.inject.TypeLiteral<T> type)
Ask Guice for the given type.
|
Route |
route() |
boolean |
secure() |
Session |
session() |
Request |
set(Class<?> type,
Object value)
Seed a
RequestScoped object. |
Request |
set(com.google.inject.Key<?> key,
Object value)
Seed a
RequestScoped object. |
Request |
set(String name,
Object value)
Set local attribute.
|
Request |
set(com.google.inject.TypeLiteral<?> type,
Object value)
Seed a
RequestScoped object. |
String |
toString() |
MediaType |
type() |
<T> Optional<T> |
unset(String name)
Remove a request local attribute.
|
static Request |
unwrap(Request req)
Unwrap a request in order to find out the target instance.
|
boolean |
xhr() |
public Forwarding(Request request)
Request.Forwarding
request.request
- A target request.public String path()
Request
http://domain.com/some/path.html -> /some/path.html http://domain.com/a.html -> /a.html
public MediaType type()
public Optional<MediaType> accepts(List<MediaType> types)
Request
// Accept: text/html req.accepts("text/html"); // => "text/html" // Accept: text/*, application/json req.accepts("text/html"); // => "text/html" req.accepts("text/html"); // => "text/html" req.accepts("application/json" "text/plain"); // => "application/json" req.accepts("application/json"); // => "application/json" // Accept: text/*, application/json req.accepts("image/png"); // => Optional.empty // Accept: text/*;q=.5, application/json req.accepts("text/html", "application/json"); // => "application/json"
public Optional<MediaType> accepts(MediaType... types)
Request
// Accept: text/html req.accepts("text/html"); // => "text/html" // Accept: text/*, application/json req.accepts("text/html"); // => "text/html" req.accepts("text/html"); // => "text/html" req.accepts("application/json" "text/plain"); // => "application/json" req.accepts("application/json"); // => "application/json" // Accept: text/*, application/json req.accepts("image/png"); // => Optional.empty // Accept: text/*;q=.5, application/json req.accepts("text/html", "application/json"); // => "application/json"
public Optional<MediaType> accepts(String... types)
Request
// Accept: text/html req.accepts("text/html"); // => "text/html" // Accept: text/*, application/json req.accepts("text/html"); // => "text/html" req.accepts("text/html"); // => "text/html" req.accepts("application/json" "text/plain"); // => "application/json" req.accepts("application/json"); // => "application/json" // Accept: text/*, application/json req.accepts("image/png"); // => Optional.empty // Accept: text/*;q=.5, application/json req.accepts("text/html", "application/json"); // => "application/json"
public boolean is(List<MediaType> types)
Request
public boolean is(MediaType... types)
Request
public boolean is(String... types)
Request
public boolean isSet(String name)
public Mutant params()
Request
/path/:name
or /path/{name}
?name=jooby
Content-Type
is
application/x-www-form-urlencoded
or multipart/form-data
public Mutant param(String name)
Request
/path/:name
or /path/{name}
?name=jooby
Content-Type
is
application/x-www-form-urlencoded
or multipart/form-data
path
, query
and body
. For
example a pattern like: GET /path/:name
for /path/jooby?name=rocks
produces:
assertEquals("jooby", req.param(name).value()); assertEquals("jooby", req.param(name).toList(String.class).get(0)); assertEquals("rocks", req.param(name).toList(String.class).get(1));Uploads can be retrieved too when
Content-Type
is multipart/form-data
see Upload
for more information.public Mutant header(String name)
Request
public Optional<Cookie> cookie(String name)
Request
public <T> T require(Class<T> type)
Request
public <T> T require(com.google.inject.TypeLiteral<T> type)
Request
public <T> T require(com.google.inject.Key<T> key)
Request
public Charset charset()
Request
application.charset
.public long length()
public Locale locale()
Request
Accept-Language
header. If the request doens't specify
such header, this method return the global locale: application.lang
.public String ip()
public int port()
public Route route()
public Session session()
public String hostname()
Request
public String protocol()
public boolean secure()
public boolean xhr()
public Map<String,Object> attributes()
Request
attributes
in interface Request
public <T> Optional<T> get(String name)
Request
public Request set(String name, Object value)
Request
public Request set(com.google.inject.Key<?> key, Object value)
Request
RequestScoped
object.public Request set(Class<?> type, Object value)
Request
RequestScoped
object.public Request set(com.google.inject.TypeLiteral<?> type, Object value)
Request
RequestScoped
object.public <T> Optional<T> unset(String name)
Request
public static Request unwrap(Request req)
req
- A request.Request.Forwarding
).Copyright © 2015. All rights reserved.