Search in sources :

Example 1 with RestSetting

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

the class SessionSetting method newHttpServer.

public ActualHttpServer newHttpServer(final Optional<Integer> port, final MocoConfig[] configs) {
    if (isResource()) {
        ActualRestServer server = new ActualRestServer(port, Optional.<HttpsCertificate>absent(), log(), configs);
        RestSetting[] settings = resource.getSettings();
        server.resource(resource.getName(), head(settings), tail(settings));
        return server;
    }
    ActualHttpServer server = ActualHttpServer.createLogServer(port, configs);
    bindTo(server);
    return server;
}
Also used : ActualRestServer(com.github.dreamhead.moco.rest.ActualRestServer) RestSetting(com.github.dreamhead.moco.RestSetting) ActualHttpServer(com.github.dreamhead.moco.internal.ActualHttpServer)

Example 2 with RestSetting

use of com.github.dreamhead.moco.RestSetting 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)

Aggregations

RestSetting (com.github.dreamhead.moco.RestSetting)2 ResponseHandler (com.github.dreamhead.moco.ResponseHandler)1 RestIdMatcher (com.github.dreamhead.moco.RestIdMatcher)1 ActualHttpServer (com.github.dreamhead.moco.internal.ActualHttpServer)1 ActualRestServer (com.github.dreamhead.moco.rest.ActualRestServer)1