package lc.esp.eo.service;

import lc.esp.engine.ESPEngine;
import lc.mecha.fabric.HandlerStatus;
import lc.mecha.http.server.HttpTransaction;
import lc.mecha.http.server.PrefixedHandler;
import lc.mecha.log.MechaLogger;
import lc.mecha.log.MechaLoggerFactory;

import java.util.Set;

/**
 * The EO front-end service. This provides EO & EOFS services to callers both internal and external.
 *
 * @author Alex Leigh
 * @since mk20 (TOKYO PROTOCOL)
 */
public class EOService {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(EOService.class);

    public static void main(String[] args) throws Exception {
        ESPEngine esp = new ESPEngine();
        esp.register(new PrefixedHandler(Set.of("/api/eo")) {
            @Override
            public HandlerStatus handlePrefixedWebRequest(HttpTransaction request) throws Throwable {
                request.httpServletResponse.getOutputStream().write("Hello World\n".getBytes());
                return HandlerStatus.BREAK;
            }
        });
        esp.runDangerously();
    }
}
