Class Route


  • public class Route
    extends Object
    Author:
    Denis Danilin | me@loslobos.ru 01.03.2023 14:27 FairHttpService ☭ sweat and blood
    • Method Detail

      • async

        public static Route async​(String method,
                                  String endpoint,
                                  BiFunction<Request,​Map<String,​String>,​CompletionStage<Response>> callback)
        Parameters:
        method - HTTP method (GET, POST, PUT, etc)
        endpoint - Fully qualified endpoint. If its patterned - it must be Java RegEx synthax compliant and groups must be correctly mappable to callback arguments
        callback - invocation of request with mapped path variables by names given in pathVarsNames
      • sync

        public static Route sync​(String method,
                                 String endpoint,
                                 BiFunction<Request,​Map<String,​String>,​Response> callback)
        Parameters:
        method - HTTP method (GET, POST, PUT, etc)
        endpoint - Fully qualified endpoint. If its patterned - it must be Java RegEx synthax compliant and groups must be correctly mappable to callback arguments
        callback - invocation of request with mapped path variables by names given in pathVarsNames
      • async

        public static Route async​(Route.Method method,
                                  String endpoint,
                                  BiFunction<Request,​Map<String,​String>,​CompletionStage<Response>> callback)
        Parameters:
        method - HTTP method (GET, POST, PUT, etc)
        endpoint - Fully qualified endpoint. If its patterned - it must be Java RegEx synthax compliant and groups must be correctly mappable to callback arguments
        callback - invocation of request with mapped path variables by names given in pathVarsNames
      • sync

        public static Route sync​(Route.Method method,
                                 String endpoint,
                                 BiFunction<Request,​Map<String,​String>,​Response> callback)
        Parameters:
        method - HTTP method (GET, POST, PUT, etc)
        endpoint - Fully qualified endpoint. If its patterned - it must be Java RegEx synthax compliant and groups must be correctly mappable to callback arguments
        callback - invocation of request with mapped path variables by names given in pathVarsNames
      • breakIf

        public Route breakIf​(BiFunction<Request,​Map<String,​String>,​Boolean> breakIfPredicate,
                             Response breakWithResponse)
        Adds condition with when successfully applied may interrupt request with given response, before any call is made to business logic
        Parameters:
        breakIfPredicate - predicate to be applied
        breakWithResponse - response to be used if condition is true
        Returns:
        route itself