public void init(Request request, Response response) {
    RequestData data = monitor.current();
    if (data == null) {
      // will happen in cases where the filter is not active
      return;
    }

    data.setCategory(Category.REST);
    if (request.getResourceRef() != null) {
      String resource = request.getResourceRef().getLastSegment();
      resource = FilenameUtils.getBaseName(resource);
      data.getResources().add(resource);
    }
    monitor.update();
  }
  public void dispatched(Request request, Response response, Restlet restlet) {
    RequestData data = monitor.current();
    if (data == null) {
      // will happen in cases where the filter is not active
      return;
    }

    if (restlet instanceof Route) {
      restlet = ((Route) restlet).getNext();
    }

    if (restlet instanceof BeanDelegatingRestlet) {
      restlet = ((BeanDelegatingRestlet) restlet).getBean();
    }

    if (restlet != null) {
      if (restlet.getClass().getPackage().getName().startsWith("org.geoserver.catalog.rest")) {
        data.setService("RESTConfig");
      }
    }

    monitor.update();
  }