Interface Request
-
public interface Request
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description io.reactivex.Maybe<Buffer>body()Get the current body request as aMaybe.voidbody(Buffer buffer)Set the current body request as aBuffer.io.reactivex.Single<Buffer>bodyOrEmpty()io.reactivex.Flowable<Buffer>chunks()Get the current request body chunks asFlowableofBuffer.voidchunks(io.reactivex.Flowable<Buffer> chunks)Set the current request body chunks from aFlowableofBuffer.StringcontextPath()booleanended()Indicates if that request is ended or not meaning that all the request headers and the request body have been fully read.HttpHeadersheaders()Stringhost()Allows to retrieve the request host.Stringid()StringlocalAddress()Returns the Internet Protocol (IP) address of the interface on which the request was received.io.gravitee.common.http.HttpMethodmethod()io.gravitee.reporter.api.http.Metricsmetrics()Get the metrics associated to the request.io.reactivex.CompletableonBody(io.reactivex.MaybeTransformer<Buffer,Buffer> onBody)Applies a transformation on the complete body given as a singleBuffer.io.reactivex.CompletableonChunk(io.reactivex.FlowableTransformer<Buffer,Buffer> onChunk)Applies a transformation on each body chunks and completes when all the chunks have been processed.io.gravitee.common.util.MultiValueMap<String,String>parameters()Stringpath()StringpathInfo()io.gravitee.common.util.MultiValueMap<String,String>pathParameters()StringremoteAddress()Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.Stringscheme()SSLSessionsslSession()longtimestamp()The timestamp for when this request was received.StringtransactionId()Propagated transaction id between multiple requests.Stringuri()io.gravitee.common.http.HttpVersionversion()
-
-
-
Method Detail
-
id
String id()
-
transactionId
String transactionId()
Propagated transaction id between multiple requests.- Returns:
- Transaction ID.
-
uri
String uri()
- Returns:
- The URL the client used to make the request.
-
host
String host()
Allows to retrieve the request host. This method should be preferred over retrieving the host from http headers.- Returns:
- the host.
-
path
String path()
- Returns:
- the part of this request's URL from the protocol name up to the query string in the first line of the HTTP request.
-
pathInfo
String pathInfo()
- Returns:
- the
pathwithout thecontext-path.
-
contextPath
String contextPath()
- Returns:
- the portion of the request URI that indicates the context of the request.
-
parameters
io.gravitee.common.util.MultiValueMap<String,String> parameters()
- Returns:
- the query parameters in the request
-
pathParameters
io.gravitee.common.util.MultiValueMap<String,String> pathParameters()
- Returns:
- the path parameters in the request
-
headers
HttpHeaders headers()
- Returns:
- the headers in the request.
-
method
io.gravitee.common.http.HttpMethod method()
- Returns:
- the HTTP method for the request.
-
scheme
String scheme()
-
version
io.gravitee.common.http.HttpVersion version()
- Returns:
- the HTTP version of the request
-
timestamp
long timestamp()
The timestamp for when this request was received. Specifically, this is the timestamp of creation of the request object.- Returns:
- the instant timestamp for the request.
-
remoteAddress
String remoteAddress()
Returns the Internet Protocol (IP) address of the client or last proxy that sent the request.- Returns:
- a
Stringcontaining the IP address of the client that sent the request.
-
localAddress
String localAddress()
Returns the Internet Protocol (IP) address of the interface on which the request was received.- Returns:
- a
Stringcontaining the IP address on which the request was received.
-
sslSession
SSLSession sslSession()
- Returns:
- SSLSession associated to the request. Returns
nullif not an SSL connection. - See Also:
SSLSession
-
metrics
io.gravitee.reporter.api.http.Metrics metrics()
Get the metrics associated to the request.- Returns:
- a
Metricsobject.
-
ended
boolean ended()
Indicates if that request is ended or not meaning that all the request headers and the request body have been fully read.- Returns:
trueif the headers and body have been read,falseelse.
-
body
io.reactivex.Maybe<Buffer> body()
Get the current body request as aMaybe. By getting the body as aMaybe, the current body chunks will be merged together to reconstruct the entire body in provide it in the form of a singleBufferThis is useful when the entire body is required to apply some transformation or any manipulation. WARN: beware that the entire body content will be loaded in memory. You should not keep a direct reference on the body chunks as they could be overridden by others at anytime.- Returns:
- a
Maybeobservable containing the current entire body request or empty if request body as not been set yet. - See Also:
bodyOrEmpty()
-
bodyOrEmpty
io.reactivex.Single<Buffer> bodyOrEmpty()
Same asbody()but returns aSingleofBufferinstead. If no body request as been set yet, it returns aSinglewith an emptyBuffer. It is a convenient way that avoid checking if the body is set or not prior to manipulate it.- Returns:
- a
Singleobservable containing the current entire body request or empty an {@link Buffer) if request body as not been set yet. - See Also:
body()
-
body
void body(Buffer buffer)
Set the current body request as aBuffer. This is useful when you want to replace the current body request with a specific content that doesn't come from a reactive chain, ex:request.body(Buffer.buffer("My custom content");WARN: replacing the request body will "drain" the previous request that was in place but occurs outside the reactive chain. You should consider usingonBody(MaybeTransformer)to change the body during the chain execution.- See Also:
onBody(MaybeTransformer),chunks(Flowable)
-
onBody
io.reactivex.Completable onBody(io.reactivex.MaybeTransformer<Buffer,Buffer> onBody)
Applies a transformation on the complete body given as a singleBuffer. Ex:request.onBody(body -> body.map(buffer ->Buffer.buffer(buffer.toString().toUpperCase())));IMPORTANT: applying a transformation on the body content loads the whole body in memory. It's up to the consumer to make sure it is safe to do that without consuming too much memory.- Parameters:
onBody- the transformation that will be applied on the body.- Returns:
- a
Completablethat completes once the body transformation has occurred.
-
chunks
io.reactivex.Flowable<Buffer> chunks()
Get the current request body chunks asFlowableofBuffer. This is useful when you want to manipulate the entire body without having to load it in memory. WARN: you should not keep a direct reference on the body chunks as they could be overridden by others at anytime.- Returns:
- a
Flowablecontaining the current body request chunks.
-
chunks
void chunks(io.reactivex.Flowable<Buffer> chunks)
Set the current request body chunks from aFlowableofBuffer. This is useful to directly pump the upstream chunks to the downstream without having to load all the chunks in memory. WARN: replacing the request body will "drain" the previous request that was in place.- Parameters:
chunks- the flowable of chunks representing the request body that will be pushed to the upstream.- See Also:
body()
-
onChunk
io.reactivex.Completable onChunk(io.reactivex.FlowableTransformer<Buffer,Buffer> onChunk)
Applies a transformation on each body chunks and completes when all the chunks have been processed. Ex:request.onChunk(chunks -> chunks.map(buffer -> Buffer.buffer(buffer.toString().toUpperCase())));IMPORTANT: applying a transformation on the body chunks loads the whole body in memory. It's up to the consumer to make sure it is safe to do that without consuming too much memory. IMPORTANT: applying a transformation on chunks completes when all chunks have been transformed. If used in a policy chain, it means that the next policy will start once all chunks have been transformed- Parameters:
onChunk- the transformer that will be applied.- Returns:
- a
Completablethat completes once the body transformation has occurred on all the chunks.
-
-