simter-reactive-web

Simter reactive extension for web

License

License

MIT
Categories

Categories

React User Interface Web Frameworks
GroupId

GroupId

tech.simter.reactive
ArtifactId

ArtifactId

simter-reactive-web
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

simter-reactive-web
Simter reactive extension for web
Project URL

Project URL

https://github.com/simter/simter-reactive-web
Project Organization

Project Organization

simter
Source Code Management

Source Code Management

https://github.com/simter/simter-reactive-web.git

Download simter-reactive-web

How to add to project

<!-- https://jarcasting.com/artifacts/tech.simter.reactive/simter-reactive-web/ -->
<dependency>
    <groupId>tech.simter.reactive</groupId>
    <artifactId>simter-reactive-web</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/tech.simter.reactive/simter-reactive-web/
implementation 'tech.simter.reactive:simter-reactive-web:1.1.0'
// https://jarcasting.com/artifacts/tech.simter.reactive/simter-reactive-web/
implementation ("tech.simter.reactive:simter-reactive-web:1.1.0")
'tech.simter.reactive:simter-reactive-web:jar:1.1.0'
<dependency org="tech.simter.reactive" name="simter-reactive-web" rev="1.1.0">
  <artifact name="simter-reactive-web" type="jar" />
</dependency>
@Grapes(
@Grab(group='tech.simter.reactive', module='simter-reactive-web', version='1.1.0')
)
libraryDependencies += "tech.simter.reactive" % "simter-reactive-web" % "1.1.0"
[tech.simter.reactive/simter-reactive-web "1.1.0"]

Dependencies

compile (11)

Group / Artifact Type Version
io.projectreactor.netty : reactor-netty Optional jar
org.springframework : spring-webflux jar
org.springframework.boot : spring-boot-autoconfigure jar
tech.simter : simter-jwt jar 1.1.0
tech.simter.reactive : simter-reactive-context jar 1.1.0
tech.simter : simter-jackson-javatime Optional jar 0.3.0
org.springframework : spring-context jar
org.springframework : spring-web jar
io.projectreactor : reactor-core jar
org.jetbrains.kotlin : kotlin-stdlib jar
org.slf4j : slf4j-api jar

test (10)

Group / Artifact Type Version
io.projectreactor : reactor-test jar
org.junit.jupiter : junit-jupiter jar
org.slf4j : jcl-over-slf4j jar
ch.qos.logback : logback-classic jar
org.springframework.boot : spring-boot-starter-test jar 2.1.6.RELEASE
org.springframework.boot : spring-boot-starter-json jar
com.fasterxml.jackson.module : jackson-module-kotlin jar
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar
com.fasterxml.jackson.datatype : jackson-datatype-jsr353 jar
org.glassfish : javax.json jar 1.1.4

Project Modules

There are no modules declared in this project.

simter-reactive-web

Simter reactive web extension. It's for webflux extension config.

1. Installation

<dependency>
  <groupId>tech.simter.reactive</groupId>
  <artifactId>simter-reactive-web</artifactId>
  <version>${VERSION}</version>
</dependency>

2. Extensions

2.1. JwtWebFilter

A Jwt WebFilter for webflux.

  • Enabled by simter.jwt.require-authorized, it's default value is false.
  • Config the Jwt secret key by simter.jwt.secret-key, it's default value is test.
  • Config the Jwt exclude array paths by simter.jwt.exclude-paths, it's default value is null.

2.2. WebFluxConfiguration

A 'WebFlux config API' implementation (implements WebFluxConfigurer interface). And some jackson global config:

  1. Some global jackson config :

    • Set serialization inclusion to NON_NULL
    • Disable some features:
      • DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
      • DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE
      • SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
    • Enable feature DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT
    • Add a custom JavaTimeModule if has dependency tech.simter:simter-jackson-javatime.

      It's a brand new java-time serialize and deserialize module with global config from simter-jackson-javatime, not the jackson standard JavaTimeModule module. It's data-time format is for localize config, not the standard ISO format. The default data-time format is like yyyy-MM-dd HH:mm, accurate to minute and without zone and offset info (global use local zone and offset default)

  2. Add a Jackson2JsonEncoder to WebFluxConfigurer/HttpMessageCodecs

  3. Add a Jackson2JsonDecoder to WebFluxConfigurer/HttpMessageCodecs

2.3. DefaultDataBufferInserter

An extension of BodyInserter that allows for write data to body through default allocate DataBuffer.

Example:

override fun handle(request: ServerRequest): Mono<ServerResponse> {
  return ok()
    .contentType(APPLICATION_OCTET_STREAM)
    .header("Content-Disposition", "attachment; filename=\"t.txt\"")
    .body(DefaultDataBufferInserter {
      // way 1: write something to this dataBuffer directly
      // it.write(...)

      // way 2: write something to outputStream from this dataBuffer
      // val os: OutputStream = it.asOutputStream()
      // write something to os, such as `os.write(...)`
    })
}

3. Build

mvn clean package
tech.simter.reactive

Versions

Version
1.1.0
1.0.0