diff --git a/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtConnectServer.java b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtConnectServer.java index 7f0d000..540ca47 100644 --- a/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtConnectServer.java +++ b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtConnectServer.java @@ -1,5 +1,6 @@ package io.github.protocol.mtconnect.server; +import io.github.shoothzj.http.facade.core.HttpMethod; import io.github.shoothzj.http.facade.server.HttpServer; import io.github.shoothzj.http.facade.server.HttpServerFactory; @@ -10,12 +11,18 @@ public class MtConnectServer { private final HttpServer httpServer; + private final MtRequestProcessor mtRequestProcessor; + public MtConnectServer(MtConnectServerConfiguration configuration) { this.config = configuration; this.httpServer = HttpServerFactory.createHttpServer(config.httpConfig()); + this.mtRequestProcessor = new MtRequestProcessor(configuration); } public CompletableFuture start() { + mtRequestProcessor.getHandlerMap().entrySet().forEach(entry -> { + httpServer.addRoute(entry.getKey(), HttpMethod.GET, mtRequestProcessor); + }); return httpServer.start(); } } diff --git a/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtHandler.java b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtHandler.java new file mode 100644 index 0000000..e4a2c2e --- /dev/null +++ b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtHandler.java @@ -0,0 +1,5 @@ +package io.github.protocol.mtconnect.server; + + +public interface MtHandler { +} diff --git a/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtHandlerImpl.java b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtHandlerImpl.java new file mode 100644 index 0000000..26073be --- /dev/null +++ b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtHandlerImpl.java @@ -0,0 +1,6 @@ +package io.github.protocol.mtconnect.server; + + + +public class MtHandlerImpl implements MtHandler { +} diff --git a/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtRequestProcessor.java b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtRequestProcessor.java new file mode 100644 index 0000000..106cd6e --- /dev/null +++ b/mtconnect-server/src/main/java/io/github/protocol/mtconnect/server/MtRequestProcessor.java @@ -0,0 +1,31 @@ +package io.github.protocol.mtconnect.server; + +import io.github.shoothzj.http.facade.core.HttpRequest; +import io.github.shoothzj.http.facade.core.HttpResponse; +import io.github.shoothzj.http.facade.server.RequestHandler; +import lombok.Getter; +import lombok.Setter; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.CompletableFuture; + +@Getter +@Setter +public class MtRequestProcessor implements RequestHandler { + private MtConnectServerConfiguration serverCfg; + + private Map handlerMap = new HashMap<>(); + + public MtRequestProcessor(MtConnectServerConfiguration serverCfg) { + this.serverCfg = serverCfg; + + handlerMap.put("/asset", new MtHandlerImpl()); + handlerMap.put("/current", new MtHandlerImpl()); + } + + @Override + public CompletableFuture handle(HttpRequest request) { + return null; + } +} diff --git a/mtconnect-server/src/test/java/io/github/protocol/mtconnect/server/MtConnectServerTest.java b/mtconnect-server/src/test/java/io/github/protocol/mtconnect/server/MtConnectServerTest.java new file mode 100644 index 0000000..e876d35 --- /dev/null +++ b/mtconnect-server/src/test/java/io/github/protocol/mtconnect/server/MtConnectServerTest.java @@ -0,0 +1,4 @@ +package io.github.protocol.mtconnect.server; + +class MtConnectServerTest { +}