https://github.com/daggerok/spring-boot-functional-servlet-example
This is a later spring web (2.2.0.BUILD-SNAPSHOT) with functional servlet functionality!
https://github.com/daggerok/spring-boot-functional-servlet-example
assembly functional gradle-kotlin-dsl gradle-zip kotlin-dsl maven-assembly maven-assembly-plugin maven-zip mvc-fn spring-functional spring-web-fuctional
Last synced: 27 days ago
JSON representation
This is a later spring web (2.2.0.BUILD-SNAPSHOT) with functional servlet functionality!
- Host: GitHub
- URL: https://github.com/daggerok/spring-boot-functional-servlet-example
- Owner: daggerok
- Created: 2019-04-05T00:39:19.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-04-05T16:37:56.000Z (about 7 years ago)
- Last Synced: 2025-01-10T00:42:23.212Z (over 1 year ago)
- Topics: assembly, functional, gradle-kotlin-dsl, gradle-zip, kotlin-dsl, maven-assembly, maven-assembly-plugin, maven-zip, mvc-fn, spring-functional, spring-web-fuctional
- Language: Java
- Size: 119 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Functional Servlet MVC [](https://travis-ci.org/daggerok/spring-boot-functional-servlet-example)
This is a later spring web (2.2.0.BUILD-SNAPSHOT) with functional servlet functionality!
## Key items
### Functional Servlet based Routes
```java
@Configuration
public class FunctionalRouter {
@Bean
public RouterFunction routes() {
return RouterFunctions.route()
.POST("/fn", request -> ServerResponse.ok().body("Functional hello!"))
.GET("/**", request -> ServerResponse.ok().body("_self: " + request.path()))
.filter((request, next) -> {
var response = next.handle(request);
var headers = HttpHeaders.writableHttpHeaders(response.headers());
headers.add("X-FUNCTIONAL", "It's fucking awesome!");
return response;
})
.build();
}
}
```
## Build, run and test
```bash
./mvnw # or: ./gradlew
java -jar ./target/*.jar # or: ./build/libs/*.jar
http :8080/fn body=world
http :8080/mvc/
http :8080/mvc body=hello
http :8080/fn/
```
## zip sources (out of topic)
```bash
./gradlew sources # or ./mvnw package
```
links:
* [YouTube: Spring Tips: WebMvc.fn - the functional DSL for Spring MVC](https://www.youtube.com/watch?v=vZV2_9KVHJU)
* [See that useful article about zip with maven assembly](https://medium.com/@kasunpdh/using-the-maven-assembly-plugin-to-build-a-zip-distribution-5cbca2a3b052)