Class CompositeResolver

java.lang.Object
com.djrapitops.plan.delivery.web.resolver.CompositeResolver
All Implemented Interfaces:
Resolver

public final class CompositeResolver extends Object implements Resolver
Utility Resolver for organizing resolution in a tree-like structure.

CompositeResolver removes first part of the target with URIPath.omitFirst() before calling the child Resolvers.

Example: resolverService.registerResolver("/test/", compositeResolver); The Resolvers added to CompositeResolver will be given Request with URIPath "/".

  • Method Details

    • builder

      public static CompositeResolver.Builder builder()
      Create a new builder for a .
      Returns:
      a builder.
    • canAccess

      public boolean canAccess(Request request)
      Description copied from interface: Resolver
      Implement access control if authorization is enabled.

      Is not called when access control is not active.

      Specified by:
      canAccess in interface Resolver
      Parameters:
      request - HTTP request, contains all information necessary to check access.
      Returns:
      true if allowed or invalid target, false if response should be 403 (forbidden)
      See Also:
    • resolve

      public Optional<Response> resolve(Request request)
      Description copied from interface: Resolver
      Implement request resolution.
      Specified by:
      resolve in interface Resolver
      Parameters:
      request - HTTP request, contains all information necessary to resolve the request.
      Returns:
      Response or empty if the response should be 404 (not found).
      See Also:
    • requiresAuth

      public boolean requiresAuth(Request request)
      Description copied from interface: Resolver
      Used to check if the resolver requires authentication to be used.
      Specified by:
      requiresAuth in interface Resolver
      Parameters:
      request - Incoming request that you can use to figure out if authentication is required.
      Returns:
      true if you want 401 to be given when user has not logged in.