webFlux route 下path与post优先级

  @Bean
    public RouterFunction<ServerResponse> doctorRoutes(DoctorHandler handler) {
        return RouterFunctions.route()
                .POST("/doctors/cart",accept(MediaType.APPLICATION_JSON),handler::addCart)
                .path("/doctors",b1 -> b1
                        .POST("/patient/{id}", accept(MediaType.APPLICATION_JSON), handler::addPatient)
                        .GET("/patients/{d_id}",accept(MediaType.APPLICATION_JSON),handler::getPatientsByDoctorId)
                        .POST( handler::save)
                    )
                .build();

上面的代码,如果把post请求/doctors/cart下移到path方法下面时会发生请求进入path方法的save处理方法中,实际调用的路径为post请求/doctors



来自为知笔记(Wiz)


posted on 2023-02-06 03:35  白衣风云  阅读(30)  评论(0编辑  收藏  举报

导航