Search in sources :

Example 1 with ResponseHandler

use of com.github.dreamhead.moco.ResponseHandler in project moco by dreamhead.

the class ContentHandler method apply.

@Override
public ResponseHandler apply(final MocoConfig config) {
    ResponseHandler handler = super.apply(config);
    if (handler != this) {
        return handler;
    }
    Resource appliedReosurce = this.resource.apply(config);
    if (appliedReosurce != this.resource) {
        return new ContentHandler((ContentResource) appliedReosurce);
    }
    return this;
}
Also used : ResponseHandler(com.github.dreamhead.moco.ResponseHandler) Resource(com.github.dreamhead.moco.resource.Resource) ContentResource(com.github.dreamhead.moco.resource.ContentResource)

Example 2 with ResponseHandler

use of com.github.dreamhead.moco.ResponseHandler in project moco by dreamhead.

the class SubResourceSetting method getMatched.

@Override
public Optional<ResponseHandler> getMatched(final RestIdMatcher resourceName, final HttpRequest httpRequest) {
    for (RestSetting setting : settings) {
        RestIdMatcher idMatcher = RestIdMatchers.match(join(resourceName.resourceUri(), this.id.resourceUri(), this.name));
        Optional<ResponseHandler> responseHandler = setting.getMatched(idMatcher, httpRequest);
        if (responseHandler.isPresent()) {
            return responseHandler;
        }
    }
    return Optional.absent();
}
Also used : RestIdMatcher(com.github.dreamhead.moco.RestIdMatcher) RestSetting(com.github.dreamhead.moco.RestSetting) ResponseHandler(com.github.dreamhead.moco.ResponseHandler)

Example 3 with ResponseHandler

use of com.github.dreamhead.moco.ResponseHandler in project moco by dreamhead.

the class BaseResponseSettingConfiguration method response.

@Override
public T response(final ResponseHandler handler, final ResponseHandler... handlers) {
    ResponseHandler responseHandler = and(checkNotNull(handler, "Handler should not be null"), checkNotNull(handlers, "Handlers should not be null"));
    this.handler = targetHandler(responseHandler);
    return self();
}
Also used : ResponseHandler(com.github.dreamhead.moco.ResponseHandler)

Aggregations

ResponseHandler (com.github.dreamhead.moco.ResponseHandler)3 RestIdMatcher (com.github.dreamhead.moco.RestIdMatcher)1 RestSetting (com.github.dreamhead.moco.RestSetting)1 ContentResource (com.github.dreamhead.moco.resource.ContentResource)1 Resource (com.github.dreamhead.moco.resource.Resource)1