Forwardings Requests to static content in Spring Boot Webflux

The following WebFilter redirects incoming requests for / to a static HTML file, index.html. ToIndexPageRedirection.java package com.hascode.tutorial; import org.springframework.stereotype.Component; import org.springframework.web.server.ServerWebExchange; import org.springframework.web.server.WebFilter; import org.springframework.web.server.WebFilterChain; import reactor.core.publisher.Mono; @Component public class ToIndexPageRedirection implements WebFilter { @Override public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) { if (exchange.getRequest().getURI().getPath().equals("/")) { return chain.filter( exchange.mutate().request( exchange.getRequest().mutate().path("/index.html").build() ).build() ); } return chain.filter(exchange); } } Ressources: JavaDocs WebFilter

August 16, 2022 · 1 min · 59 words · Micha Kops

Reactive Streams – Java 9 Flow API, RxJava, Akka and Reactor Examples

Reactive Streams is an initiative trying to standardize asynchronous stream processing with non-blocking back-pressure. With Java 9, new classes in the java.util.concurrent.flow package offer a semantically equivalent counterpart to this standard that may be adopted by other frameworks. In the following short tutorial we’re implementing examples for reactive streams with Java 9 and the Flow API, with RxJava2, with Akka, with Reactor and finally there is an example in RxJava1, too though it does not follow the standard. ...

January 14, 2018 · 8 min · 1550 words · Micha Kops

Downloading Maven Artifacts from a POM file programmatically with Eclipse Aether

Sometimes I need to resolve Maven dependencies programmatically. Eclipse Aether is a library for working with artifact repositories and I’ll be using it in the following example to read dependency trees from a given POM descriptor file and download each dependency from a remote Maven repository to a local directory. Figure 1. Using Eclipse Aether. Dependencies We’re adding a bunch of dependencies to our project’s pom.xml: <properties> <aetherVersion>1.1.0</aetherVersion> <mavenVersion>3.2.1</mavenVersion> </properties> ...

September 8, 2017 · 5 min · 1006 words · Micha Kops