public interface RequestContextRunner
RequestContextRunner
is the main entry to spawn a new RequestContext
with adapted UserInfo
or ParameterInfo
.
The current parameters of the calling RequestContext
are not affected.RequestContextRunner user(UserInfo userInfo)
UserInfo
for the RequestContext
being opened.userInfo
- The UserInfo
.default RequestContextRunner clearUser()
UserInfo
for the RequestContext
being opened. The empty user is anonymous.RequestContextRunner anonymousUser()
UserInfo
for the RequestContext
to the anonymous user.
This user is the base-line also used by clearUser()
.RequestContextRunner providedUser()
UserInfo
for the RequestContext
as provided by the UserInfoProvider
.
By default this means the UserInfo
is resolved from the HTTP request.
You may override the default provider during runtime configuration phase by means of CdsRuntimeConfigurer.provider(UserInfoProvider)
.RequestContextRunner privilegedUser()
UserInfo
for the RequestContext
to the internal privileged user who passes all authorization checks.RequestContextRunner modifyUser(Consumer<ModifiableUserInfo> contextUser)
RequestContext
with an adapted UserInfo
.
The passed ModifiableUserInfo
API can be used to define modifications which are valid within the scope of the new RequestContext
.
The modifications are done on the UserInfo
of the outer RequestContext
if existing.
Otherwise they are done on the provided UserInfo
from UserInfoProvider
.
contextUser
- the ModifiableUserInfo
as modification layer on top of current UserInfo
RequestContextRunner parameters(ParameterInfo parameterInfo)
ParameterInfo
for the RequestContext
being opened.parameterInfo
- the ParameterInfo
.RequestContextRunner featureToggles(FeatureTogglesInfo featureTogglesInfo)
FeatureTogglesInfo
for the RequestContext
being opened.featureTogglesInfo
- the FeatureTogglesInfo
.RequestContextRunner clearParameters()
ParameterInfo
for the RequestContext
being opened.RequestContextRunner providedParameters()
ParameterInfo
for the RequestContext
as provided by the ParameterInfoProvider
.
By default this means the ParameterInfo
is resolved from the HTTP request.
You may override the default provider during runtime configuration phase by means of CdsRuntimeConfigurer.provider(ParameterInfoProvider)
.RequestContextRunner recalculateFeatureToggles()
FeatureTogglesInfo
from the currently set UserInfo
using the FeatureTogglesInfoProvider
.RequestContextRunner modifyParameters(Consumer<ModifiableParameterInfo> contextParameters)
RequestContext
with an adapted ParameterInfo
.
The passed ModifiableParameterInfo
API can be used to define modifications which are valid within the scope of the new RequestContext
.
The modifications are done on the ParameterInfo
of the outer RequestContext
if existing.
Otherwise they are done on the provided ParameterInfo
from ParameterInfoProvider
.
contextParameters
- the ModifiableParameterInfo
as modification layer on top of current ParameterInfo
RequestContextRunner clearMessages()
Messages
for the RequestContext
being opened.<T> T run(Function<RequestContext,T> requestHandler)
RequestContext
and runs the given handler within its scope.
The RequestContext
will be propagated to all
EventContext
instances in the service call hierarchy.T
- The type of the responserequestHandler
- The handler for processing the request within the contextvoid run(Consumer<RequestContext> requestHandler)
RequestContext
and runs the given handler within its scope.
The RequestContext
will be propagated to all EventContext
instances in the service call hierarchy.
If UserInfo
has not been specified explicitly, it is taken from the outer RequestContext
or, if there is no outer context, from UserInfoProvider
.
The same holds for ParameterInfo
.
requestHandler
- The handler for processing the request within the contextCopyright © 2021. All rights reserved.