Class RoutedService

java.lang.Object
com.invirgance.convirgance.web.service.RoutedService
All Implemented Interfaces:
Routable, Service

@Wiring public class RoutedService extends Object implements Service, Routable
Routes requests between multiples services based on the request URL. URLs can contain * to handle cases where the component of the URL is not known ahead of time. e.g. /owner/32/pet/12 would match /owner/*/pet.

Longer paths are checked before shorter paths, so /owner/32/pet/12 would match /owner/*/pet instead of /owner.

Conversely /owner/32/edit would match /owner.
Author:
jbanes
  • Constructor Details

    • RoutedService

      public RoutedService()
  • Method Details

    • getRoutes

      public Map<String,Service> getRoutes()
      The list of paths for routing and the service configured to handle each route.
      Returns:
      a map of routes
    • setRoutes

      public void setRoutes(Map<String,Service> routes)
      Set the list of paths and the associated services to handle those paths
      Parameters:
      routes - a map of routes
    • getDestinationService

      public Service getDestinationService(HttpRequest request)
      Description copied from interface: Routable
      Obtain the service that will handle this request.
      Specified by:
      getDestinationService in interface Routable
      Parameters:
      request - the object representing the http request
      Returns:
      the service that will handle this request, or null if it cannot be routed
    • execute

      public void execute(HttpRequest request, HttpResponse response)
      Description copied from interface: Service
      Executes the service, processing the HTTP request and generating a response.
      Specified by:
      execute in interface Service
      Parameters:
      request - The HTTP request to process
      response - The HTTP response to populate