Request.Forwarding
Constructor and Description |
---|
RequestImpl(com.google.inject.Injector injector,
NativeRequest req,
int port,
Route route,
Map<Object,Object> scope,
Map<String,Object> locals) |
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.
|
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() |
void |
done() |
<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() |
long |
length() |
Locale |
locale()
Get the content of the
Accept-Language header. |
Mutant |
param(String name)
Get a HTTP request parameter under the given name.
|
Mutant |
params()
Get all the available parameters.
|
int |
port() |
String |
protocol() |
<T> T |
require(com.google.inject.Key<T> key)
Ask Guice for the given type.
|
Route |
route() |
boolean |
secure() |
Session |
session() |
Request |
set(com.google.inject.Key<?> key,
Object value)
Seed a
RequestScoped object. |
Request |
set(String name,
Object value)
Set local attribute.
|
String |
toString() |
MediaType |
type() |
<T> Optional<T> |
unset(String name)
Remove a request local attribute.
|
public <T> Optional<T> get(String name)
Request
public Map<String,Object> attributes()
Request
attributes
in interface Request
public <T> Optional<T> unset(String name)
Request
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 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(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 Route route()
public String hostname()
Request
public int port()
public Session session()
public String protocol()
public boolean secure()
public Request set(String name, Object value)
Request
public Request set(com.google.inject.Key<?> key, Object value)
Request
RequestScoped
object.public void done()
Copyright © 2015. All rights reserved.