/** * The transient language will be taken into account when using {@link MessagesApi#preferred(RequestHeader)}} (It will take precedence over any other language). * * @return The current transient language of this request. */ default Optional<Lang> transientLang() { return attrs().getOptional(Messages.Attrs.CurrentLang).map(play.api.i18n.Lang::asJava); }
/** * The request id. The request id is stored as an attribute indexed by {@link RequestAttrKey#Id()}. */ default Long id() { return (Long) attrs().get(RequestAttrKey.Id().asJava()); }
/** * Get the request attributes. * @return the request builder's request attributes. */ public TypedMap attrs() { return new TypedMap(req.attrs()); }
/** * Returns a simple request builder. The initial request is "GET / HTTP/1.1" from * 127.0.0.1 over an insecure connection. The request is created using the given * factory. * @param requestFactory the incoming request factory */ public RequestBuilder(RequestFactory requestFactory) { req = requestFactory.createRequest( RemoteConnection$.MODULE$.apply("127.0.0.1", false, OptionConverters.toScala(Optional.empty())), "GET", RequestTarget$.MODULE$.apply("/", "/", Map$.MODULE$.empty()), "HTTP/1.1", Headers$.MODULE$.create(), TypedMap.empty().asScala(), new RequestBody(null) ); }
/** * @deprecated Deprecated as of 2.7.0. */ @Deprecated protected TypedMap ctxRequestAttrs() { return Http.Context.safeCurrent().map(ctx -> ctx.request().attrs()).orElseGet(() -> TypedMap.empty()); }
/** * Update the request attributes. This replaces all existing attributes. * * @param newAttrs The attribute entries to add. * @return the request builder with extra attributes set. */ public RequestBuilder attrs(TypedMap newAttrs) { req = req.withAttrs(newAttrs.asScala()); return this; }
/** * @param entries the list of typed entries * @return a newly built <code>TypedMap</code> from a list of keys and values. */ public static TypedMap create(TypedEntry<?>... entries) { return empty.putAll(entries); } }
/** * Check if there is a deferred action in the request. * * @param request the request * @return true if there is a deferred action in the request */ public boolean isDeferred(final Http.RequestHeader request) { return request.attrs().containsKey(ACTION_DEFERRED); }
/** * Returns a simple request builder. The initial request is "GET / HTTP/1.1" from * 127.0.0.1 over an insecure connection. The request is created using the given * factory. * @param requestFactory the incoming request factory */ public RequestBuilder(RequestFactory requestFactory) { req = requestFactory.createRequest( RemoteConnection$.MODULE$.apply("127.0.0.1", false, OptionConverters.toScala(Optional.empty())), "GET", RequestTarget$.MODULE$.apply("/", "/", Map$.MODULE$.empty()), "HTTP/1.1", Headers$.MODULE$.create(), TypedMap.empty().asScala(), new RequestBody(null) ); }
/** * @deprecated Deprecated as of 2.7.0. */ @Deprecated protected TypedMap ctxRequestAttrs() { return Http.Context.safeCurrent().map(ctx -> ctx.request().attrs()).orElseGet(() -> TypedMap.empty()); }
/** * Update the request attributes. This replaces all existing attributes. * * @param newAttrs The attribute entries to add. * @return the request builder with extra attributes set. */ public RequestBuilder attrs(TypedMap newAttrs) { req = req.withAttrs(newAttrs.asScala()); return this; }
/** * @param entries the list of typed entries * @return a newly built <code>TypedMap</code> from a list of keys and values. */ public static TypedMap create(TypedEntry<?>... entries) { return empty.putAll(entries); } }
/** * Check if there is a deferred action in the request. * * @param request the request * @return true if there is a deferred action in the request */ public boolean isDeferred(final Http.RequestHeader request) { return request.attrs().containsKey(ACTION_DEFERRED); }
/** * The transient language will be taken into account when using {@link MessagesApi#preferred(RequestHeader)}} (It will take precedence over any other language). * * @return The current transient language of this request. */ default Optional<Lang> transientLang() { return attrs().getOptional(Messages.Attrs.CurrentLang).map(play.api.i18n.Lang::asJava); }
/** * The request id. The request id is stored as an attribute indexed by {@link RequestAttrKey#Id()}. */ default Long id() { return (Long) attrs().get(RequestAttrKey.Id().asJava()); }
/** * Returns a simple request builder. The initial request is "GET / HTTP/1.1" from * 127.0.0.1 over an insecure connection. The request is created using the given * factory. * @param requestFactory the incoming request factory */ public RequestBuilder(RequestFactory requestFactory) { req = requestFactory.createRequest( RemoteConnection$.MODULE$.apply("127.0.0.1", false, OptionConverters.toScala(Optional.empty())), "GET", RequestTarget$.MODULE$.apply("/", "/", Map$.MODULE$.empty()), "HTTP/1.1", Headers$.MODULE$.create(), TypedMap.empty().asScala(), new RequestBody(null) ); }
/** * Get the request attributes. * @return the request builder's request attributes. */ public TypedMap attrs() { return new TypedMap(req.attrs()); }
/** * @deprecated Deprecated as of 2.7.0. */ @Deprecated protected TypedMap ctxRequestAttrs() { return Http.Context.safeCurrent().map(ctx -> ctx.request().attrs()).orElseGet(() -> TypedMap.empty()); }
/** * Update the request attributes. This replaces all existing attributes. * * @param newAttrs The attribute entries to add. * @return the request builder with extra attributes set. */ public RequestBuilder attrs(TypedMap newAttrs) { req = req.withAttrs(newAttrs.asScala()); return this; }
/** * @param entries the list of typed entries * @return a newly built <code>TypedMap</code> from a list of keys and values. */ public static TypedMap create(TypedEntry<?>... entries) { return empty.putAll(entries); } }