Пример #1
0
  @Override
  public void resource(final String name, final RestSetting... settings) {
    checkNotNullOrEmpty(name, "Resource name should not be null");
    checkNotNull(settings, "Rest settings should not be null");

    this.request(InternalApis.context(resourceRoot(name)))
        .response(new RestHandler(name, settings));
  }
Пример #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;
  }