/ src / test / java / ru / zoommax / examples / NotAnnotatedStart.java
NotAnnotatedStart.java
 1  package ru.zoommax.examples;
 2  
 3  import ru.zoommax.SimpleServer;
 4  import ru.zoommax.next.Response;
 5  import ru.zoommax.next.handlers.GetHandlerNew;
 6  
 7  import java.util.HashMap;
 8  
 9  public class NotAnnotatedStart {
10      //Initialization of server with port 12345 and 4 threads and start it
11      public static void main(String[] args) {
12          SimpleServer.start(12345, 4);
13          test();
14      }
15  
16      //Add endpoint using SimpleServer.addEndpoint()
17      public static void test() {
18          SimpleServer.addEndpoint("/test", new GetHandlerNew() {
19              @Override
20              public Response response(String request, HashMap<String, String> requestHeaders, HashMap<String, String> requestParams, String clientIp) {
21                  //Endpoint logic
22                  String body = request;
23                  //...
24                  return Response.builder()
25                          .bodyAsString(body)
26                          .statusCode(200)
27                          .build();
28              }
29          });
30      }
31  }