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;
}
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();
}
Aggregations