spring-webflux

Spring Boot WebFlux Reactive MongoDB: how to switch the database on each request?

会有一股神秘感。 提交于 2020-04-18 05:35:15
问题 I'm working on a SaaS project using Spring WebFlux and Reactive MongoDB. It needs to be a MultiTenant application and each tenant must use its own database. As for now I just added the Reactive MongoDB dependency to the pom.xml : <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId> <version>2.2.6.RELEASE</version> </dependency> Then I extended the AbstractReactiveMongoConfiguration in order to provide the MongoClient and

Spring WebClient: Retry with WebFlux.fn + reactor-addons

点点圈 提交于 2020-04-18 03:49:23
问题 I'm trying to add a conditional Retry for WebClient with Kotlin Coroutines + WebFlux.fn + reactor-addons: suspend fun ClientResponse.asResponse(): ServerResponse = status(statusCode()) .headers { headerConsumer -> headerConsumer.addAll(headers().asHttpHeaders()) } .body(bodyToMono(DataBuffer::class.java), DataBuffer::class.java) .retryWhen { Retry.onlyIf { ctx: RetryContext<Throwable> -> (ctx.exception() as? WebClientResponseException)?.statusCode in retryableErrorCodes } .exponentialBackoff

Spring WebClient: Retry with WebFlux.fn + reactor-addons

允我心安 提交于 2020-04-18 03:49:07
问题 I'm trying to add a conditional Retry for WebClient with Kotlin Coroutines + WebFlux.fn + reactor-addons: suspend fun ClientResponse.asResponse(): ServerResponse = status(statusCode()) .headers { headerConsumer -> headerConsumer.addAll(headers().asHttpHeaders()) } .body(bodyToMono(DataBuffer::class.java), DataBuffer::class.java) .retryWhen { Retry.onlyIf { ctx: RetryContext<Throwable> -> (ctx.exception() as? WebClientResponseException)?.statusCode in retryableErrorCodes } .exponentialBackoff

Enable wildcard in CORS spring security + webFlux

生来就可爱ヽ(ⅴ<●) 提交于 2020-04-16 03:26:11
问题 I have spring security + CORS enable into a project that is made with spring webFlux. My problem here is that we accept for example requests from: http://localhost:4200. How I can make that CORS will accept reqs from http://*.localhost:4200 like http://a.localhost:4200, http://b.localhost:4200 ? My CORS config looks like: @Bean @Order(Ordered.HIGHEST_PRECEDENCE) public CorsWebFilter corsFilter() { UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();

Creating custom ErrorWebExceptionHandler fails

本秂侑毒 提交于 2020-04-09 18:09:29
问题 I am trying to create my own ErrorWebExceptionHandler in Spring Boot 2 by extending the default one but my application fails to start with the following message: Caused by: java.lang.IllegalArgumentException: Property 'messageWriters' is required at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.afterPropertiesSet(AbstractErrorWebExceptionHandler.java:214) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE] My handler (Kotlin code):

Spring Webflux 415 with MultipartFile

╄→гoц情女王★ 提交于 2020-04-08 08:51:39
问题 I am currently trying to upload a file from an Angular 4 front-end to a Spring Webflux controller. The controller is able to read the @RequestPart value but throws a 415 UnsupportedMediaTypeStatusException. UploadController @PostMapping( consumes = MediaType.MULTIPART_FORM_DATA_VALUE ) public Mono<Void> save(@RequestPart("file")MultipartFile file) { log.info("Storing a new file. Recieved by Controller"); this.storageService.store(file); return Mono.empty(); } The log.info() method does not

Spring Webflux 415 with MultipartFile

前提是你 提交于 2020-04-08 08:51:09
问题 I am currently trying to upload a file from an Angular 4 front-end to a Spring Webflux controller. The controller is able to read the @RequestPart value but throws a 415 UnsupportedMediaTypeStatusException. UploadController @PostMapping( consumes = MediaType.MULTIPART_FORM_DATA_VALUE ) public Mono<Void> save(@RequestPart("file")MultipartFile file) { log.info("Storing a new file. Recieved by Controller"); this.storageService.store(file); return Mono.empty(); } The log.info() method does not

Reactive-Spring-Security-5.1.3.RELEASE, multiple authorizations

橙三吉。 提交于 2020-03-26 05:56:07
问题 We have some endpoints, that are secured and before to access them we're verifying that the jws is correctly. In order to do that, we've defined a SecurityContext that actually persist the Auth pojo and to manipulate it downstream into the controller. The SecurityWebFilterChain config looks like that: @Bean public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { return http.csrf().disable() .formLogin().disable() .logout().disable() .httpBasic().disable()

Reactive-Spring-Security-5.1.3.RELEASE, multiple authorizations

回眸只為那壹抹淺笑 提交于 2020-03-26 05:56:06
问题 We have some endpoints, that are secured and before to access them we're verifying that the jws is correctly. In order to do that, we've defined a SecurityContext that actually persist the Auth pojo and to manipulate it downstream into the controller. The SecurityWebFilterChain config looks like that: @Bean public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) { return http.csrf().disable() .formLogin().disable() .logout().disable() .httpBasic().disable()

WebFlux.fn doesn't route at all

耗尽温柔 提交于 2020-03-25 13:41:30
问题 I'm trying to use WebFlux.fn. I wrote a Web controller and it works. @RestController @RequestMapping(path = "/api/v1/employees") public class EmployeesController { @RequestMapping(method = GET, path = "/{id:.+}", produces = APPLICATION_JSON_VALUE) public ResponseEntity<Employee> read( @PathVariable(name = "id) String id) { } @ResponseStatus(NO_CONTENT) @RequestMapping(method = PUT, path = "/{id:.+}", consumes = APPLICATION_JSON_VALUE) public void updated(@PathVariable(name = "id") String id,