Request.Forwarding, Request.Module
Constructor and Description |
---|
UndertowRequest(io.undertow.server.HttpServerExchange exchange,
com.google.inject.Injector injector,
Route route,
Map<String,Object> locals,
BodyConverterSelector selector,
MediaType contentType,
List<MediaType> accept,
Charset charset,
Locale locale) |
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() |
<T> T |
body(com.google.inject.TypeLiteral<T> type)
Convert the HTTP request body into the given type.
|
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 named object.
|
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.
|
Map<String,Mutant> |
params()
Get all the available parameters.
|
<T> T |
params(Class<T> beanType)
Inject headers, path and query params into the given type.
|
String |
protocol() |
<T> T |
require(com.google.inject.Key<T> key)
Ask Guice for the given type.
|
Route |
route() |
void |
route(Route route) |
boolean |
secure() |
Session |
session() |
Request |
set(String name,
Object value)
Set a local using a the given name.
|
String |
toString() |
MediaType |
type() |
Request |
unset()
Unset/remove all the session data.
|
<T> Optional<T> |
unset(String name)
Remove a local value (if any) from session locals.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
public <T> Optional<T> get(String name)
Locals
public Map<String,Object> attributes()
attributes
in interface Locals
public <T> Optional<T> unset(String name)
Locals
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 Map<String,Mutant> params() throws Exception
Request
/path/:name
or /path/{name}
?name=jooby
Content-Type
is
application/x-www-form-urlencoded
or multipart/form-data
public <T> T params(Class<T> beanType) throws Exception
Request
/path/:name
or /path/{name}
?name=jooby
public Mutant param(String name) throws Exception
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).stringValue()); 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 body(com.google.inject.TypeLiteral<T> type) throws Exception
Request
public <T> T require(com.google.inject.Key<T> key)
Request
require
in interface Request
T
- Service type.key
- A service key.Request.Module
public Charset charset()
Request
application.charset
.public Locale locale()
Request
Accept-Language
header. If the request doens't specify
such header, this method return the global locale: application.lang
.public long length()
public String ip()
public Route route()
public String hostname()
Request
public Session session()
public String protocol()
public boolean secure()
public Request set(String name, Object value)
Locals
public Request unset()
Locals
public void route(Route route)
Copyright © 2015. All rights reserved.