@Override
  @SuppressWarnings("unchecked")
  public ResponseHandler apply(final MocoConfig config) {
    if (config.isFor(MocoConfig.URI_ID)) {
      String newLocalBase = (String) config.apply(proxyConfig.localBase());
      return new ProxyBatchResponseHandler(
          from(newLocalBase).to(proxyConfig.remoteBase()), failover());
    }

    return this;
  }
示例#2
0
  @Override
  @SuppressWarnings("unchecked")
  public Setting<HttpResponseSetting> apply(final MocoConfig config) {
    RequestMatcher appliedMatcher = configItem(this.matcher, config);
    if (config.isFor(MocoConfig.URI_ID) && this.matcher == appliedMatcher) {
      appliedMatcher =
          new AndRequestMatcher(
              of(appliedMatcher, InternalApis.context((String) config.apply(""))));
    }

    HttpSetting setting = new HttpSetting(appliedMatcher);
    setting.handler = configItem(this.handler, config);
    setting.eventTriggers = configItems(eventTriggers, config);
    return setting;
  }
    @Override
    public Resource apply(MocoConfig config, Resource resource) {
      if (config.isFor(id())) {
        return newResource(config);
      }

      return resource;
    }
  @Override
  public RequestMatcher apply(final MocoConfig config) {
    if (config.isFor(resource.id())) {
      return new XmlRequestMatcher(this.extractor, resource.apply(config));
    }

    return this;
  }