Spring Webflux Server Netty - как реализовать базовую безопасность http - PullRequest
0 голосов
/ 03 ноября 2018

Я реализовал свой сервер веб-службы следующим образом. Как я могу реализовать базовую защиту http для всех моих конечных точек?

     public static void main(String[] args) {
         new MesServerApplication().serve();
     }

     private void serve() {
         RouterFunction route = nest(path("/api"),
                 route(GET("/time"), DateTimeController.getTime())
                         .andRoute(GET("/time/ms"), DateTimeController.getTimeMS())
                         .andRoute(GET("/unit/all"), getUnits())
                         .andRoute(GET("/unit/{unitCode}"), getUnit())
                         .andRoute(GET("/employee/all"), getEmnos())
                         .andRoute(GET("/employee/{emnoCode}"), getEmno())
                         .andRoute(GET("/machine/all"), getMachines())
                         .andRoute(GET("/machine/{mcnoCode}"), getMachine())
                         .andRoute(GET("/substation/all"), getSubstations())
                         .andRoute(GET("/substation/{mcnoCode}"), getMachineSubstations())
                         .andRoute(GET("/substation/{mcnoCode}/{smcnCode}"), getSubstation())
                         .andRoute(GET("/messages"), getMessages())
                         .andRoute(POST("/messages"), postMessages())
                         .andRoute(POST("/unit"), postUnit())
                         .andRoute(POST("/employee"), postEmno())
                         .andRoute(POST("/machine"), postMachine())
         );

         HttpHandler httpHandler = RouterFunctions.toHttpHandler(route);
         HttpServer server = HttpServer.create("localhost", 8080);
         ReactorHttpHandlerAdapter myReactorHandler = new ReactorHttpHandlerAdapter(httpHandler);
         server.startAndAwait(myReactorHandler);
     }
...