Class Directives$


  • public class Directives$
    extends AllDirectives
    Collects all default directives into one class for simple importing of static functions.

    See Directives for ScalaDSL equivalent of this class.

    • Field Detail

      • MODULE$

        public static final Directives$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • Directives$

        public Directives$()
    • Method Detail

      • anyOf

        public Route anyOf​(java.util.function.Function<java.util.function.Supplier<Route>,​Route> first,
                           java.util.function.Function<java.util.function.Supplier<Route>,​Route> second,
                           java.util.function.Supplier<Route> inner)
        Composes two 0-argument directives which share the same inner Route. This is equivalent to first(inner).orElse(second(inner)) Usage example: anyOf(this::get, this::post, () -> complete("hi")))
        Parameters:
        first - the first 0-argument directive
        second - the second 0-argument directive
        inner - the inner route Producer
        Returns:
        the resulting route
      • anyOf

        public <A> Route anyOf​(java.util.function.Function<java.util.function.Function<A,​Route>,​Route> first,
                               java.util.function.Function<java.util.function.Function<A,​Route>,​Route> second,
                               java.util.function.Function<A,​Route> inner)
        Composes two 1-argument directives (directives whose inner route takes a parameter) which share the same inner route. This is the same as first(inner).orElse(second(inner)). This can be used also for directives that take an additional parameter if the directive is partially applied, ie. parameter Usage example: anyOf(bindParameter(this::path, "bar"), bindParameter(this::path, "baz"), () -> complete("bar or baz"))
        Parameters:
        first - the first 1-argument directive
        second - the second 1-argument directive
        inner - the inner route that takes one argument
        Returns:
        the resulting route
      • allOf

        public Route allOf​(java.util.function.Function<java.util.function.Supplier<Route>,​Route> first,
                           java.util.function.Function<java.util.function.Supplier<Route>,​Route> second,
                           java.util.function.Supplier<Route> inner)
        Nests two 0-argument directives together Usage example: allOf(bindParameter(this::pathPrefix, "alice"), bindParameter(this::path, "bob"), () -> complete("Charlie!"))
        Parameters:
        first - the 0-argument directive (outer one)
        second - the 0-argument directive (inner one)
        inner - the inner route function
        Returns:
        the resulting route
      • allOf

        public <A,​B> Route allOf​(java.util.function.Function<java.util.function.Function<A,​Route>,​Route> first,
                                       java.util.function.Function<java.util.function.Function<B,​Route>,​Route> second,
                                       java.util.function.BiFunction<A,​B,​Route> inner)
        Nests two 1-argument directives together Usage example: allOf(this::extractScheme, this::extractMethod, (scheme, method) -> complete("You did a " + method.name() + " using " + scheme))
        Parameters:
        first - the first 1-argument directive (outer one)
        second - the second 1-argument directive (inner one)
        inner - the inner route function that takes 2 different parameters
        Returns:
        the resulting route
      • allOf

        public <A> Route allOf​(java.util.function.Function<java.util.function.Supplier<Route>,​Route> first,
                               java.util.function.Function<java.util.function.Function<A,​Route>,​Route> second,
                               java.util.function.Function<A,​Route> inner)
        Nests one 0-argument and 1-argument directives together Usage example: allOf(bindParameter(this::pathPrefix, "guess"), this::extractMethod, method -> complete("You did a " + method.name()))
        Parameters:
        first - the 0-argument directive (outer one)
        second - the 1-argument directive (inner one)
        inner - the inner route function that takes 1 parameter
        Returns:
        the resulting route