Search in sources :

Example 1 with ActualHttpServer

use of com.github.dreamhead.moco.internal.ActualHttpServer 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 ActualHttpServer

use of com.github.dreamhead.moco.internal.ActualHttpServer in project moco by dreamhead.

the class HttpServerParser method createServer.

@Override
protected HttpServer createServer(final ImmutableList<SessionSetting> sessionSettings, final Optional<Integer> port, final MocoConfig... configs) {
    ActualHttpServer targetServer = ActualHttpServer.createLogServer(port, configs);
    for (SessionSetting session : sessionSettings) {
        logger.debug("Parse session: {}", session);
        targetServer = targetServer.mergeServer(session.newHttpServer(port, configs));
    }
    return targetServer;
}
Also used : ActualHttpServer(com.github.dreamhead.moco.internal.ActualHttpServer) SessionSetting(com.github.dreamhead.moco.parser.model.SessionSetting)

Example 3 with ActualHttpServer

use of com.github.dreamhead.moco.internal.ActualHttpServer in project moco by dreamhead.

the class HttpServerParser method createServer.

@Override
protected HttpServer createServer(final ImmutableList<SessionSetting> sessionSettings, final int port, final MocoConfig... configs) {
    ActualHttpServer targetServer = ActualHttpServer.createLogServer(port, configs);
    for (SessionSetting session : sessionSettings) {
        logger.debug("Parse session: {}", session);
        targetServer = targetServer.mergeServer(session.newHttpServer(port, configs));
    }
    return targetServer;
}
Also used : ActualHttpServer(com.github.dreamhead.moco.internal.ActualHttpServer) SessionSetting(com.github.dreamhead.moco.parser.model.SessionSetting)

Example 4 with ActualHttpServer

use of com.github.dreamhead.moco.internal.ActualHttpServer in project moco by dreamhead.

the class MocoJsonRunner method jsonHttpsServer.

public static HttpsServer jsonHttpsServer(final Resource resource, final HttpsCertificate certificate) {
    checkNotNull(certificate, "Certificate should not be null");
    ActualHttpServer httpsServer = (ActualHttpServer) Moco.httpsServer(certificate);
    return httpsServer.mergeServer((ActualHttpServer) parseHttpServer(checkNotNull(resource, "resource should not be null"), 0));
}
Also used : ActualHttpServer(com.github.dreamhead.moco.internal.ActualHttpServer)

Example 5 with ActualHttpServer

use of com.github.dreamhead.moco.internal.ActualHttpServer in project moco by dreamhead.

the class MocoJsonRunner method jsonHttpsServer.

public static HttpsServer jsonHttpsServer(final int port, final Resource resource, final HttpsCertificate certificate) {
    checkArgument(port > 0, "Port must be greater than zero");
    checkNotNull(certificate, "Certificate should not be null");
    ActualHttpServer httpsServer = (ActualHttpServer) Moco.httpsServer(port, certificate);
    return httpsServer.mergeServer((ActualHttpServer) parseHttpServer(checkNotNull(resource, "resource should not be null"), port));
}
Also used : ActualHttpServer(com.github.dreamhead.moco.internal.ActualHttpServer)

Aggregations

ActualHttpServer (com.github.dreamhead.moco.internal.ActualHttpServer)6 RestSetting (com.github.dreamhead.moco.RestSetting)2 SessionSetting (com.github.dreamhead.moco.parser.model.SessionSetting)2 ActualRestServer (com.github.dreamhead.moco.rest.ActualRestServer)2