Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
1.1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
sokomishalov committed Jul 15, 2020
1 parent f56cbc1 commit 0f2c48e
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 82 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add the dependency:
<dependency>
<groupId>com.github.sokomishalov.commons</groupId>
<artifactId>commons-[module]</artifactId>
<version>1.1.15</version>
<version>1.1.16</version>
</dependency>
```

Expand Down
2 changes: 1 addition & 1 deletion commons-logging/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>${logback.version}</version>
<scope>test</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ interface Loggable {

val logger: Logger get() = CustomLoggerFactory.getLogger(javaClass)

@Deprecated("Use logInfo() instead", replaceWith = ReplaceWith("logInfo(s)"))
fun log(s: String?) = logger.info(s)

@Deprecated("Use logInfo() instead", replaceWith = ReplaceWith("logInfo(lazyMessage)"))
fun log(lazyMessage: () -> String?) = logger.info(lazyMessage)

fun logInfo(s: String?) = logger.info(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,18 @@
package ru.sokomishalov.commons.spring.config

import org.springframework.http.codec.ServerCodecConfigurer
import org.springframework.http.codec.json.Jackson2JsonDecoder
import org.springframework.http.codec.json.Jackson2JsonEncoder
import org.springframework.web.reactive.config.CorsRegistry
import org.springframework.web.reactive.config.ResourceHandlerRegistry
import org.springframework.web.reactive.config.WebFluxConfigurer
import ru.sokomishalov.commons.spring.serialization.JACKSON_DECODER
import ru.sokomishalov.commons.spring.serialization.JACKSON_ENCODER
import ru.sokomishalov.commons.core.serialization.OBJECT_MAPPER

open class CustomWebFluxConfigurer : WebFluxConfigurer {

override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.apply {
addResourceHandler("/swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/")
addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/")
}
}

override fun configureHttpMessageCodecs(configurer: ServerCodecConfigurer) {
configurer.defaultCodecs().apply {
jackson2JsonEncoder(JACKSON_ENCODER)
jackson2JsonDecoder(JACKSON_DECODER)
jackson2JsonEncoder(Jackson2JsonEncoder(OBJECT_MAPPER))
jackson2JsonDecoder(Jackson2JsonDecoder(OBJECT_MAPPER))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,23 @@

package ru.sokomishalov.commons.spring.config

import org.springframework.http.converter.HttpMessageConverter
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
import org.springframework.scheduling.concurrent.ConcurrentTaskExecutor
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer
import org.springframework.web.servlet.config.annotation.CorsRegistry
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
import ru.sokomishalov.commons.core.serialization.OBJECT_MAPPER
import java.util.concurrent.Executors

open class CustomWebMvcConfigurer : WebMvcConfigurer {

override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.apply {
addResourceHandler("/swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/")
addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/")
}
override fun configureMessageConverters(converters: MutableList<HttpMessageConverter<*>>) {
converters += MappingJackson2HttpMessageConverter(OBJECT_MAPPER)
}

override fun configureAsyncSupport(configurer: AsyncSupportConfigurer) {
configurer.setTaskExecutor(ConcurrentTaskExecutor(Executors.newCachedThreadPool()))
}

override fun addCorsMappings(registry: CorsRegistry) {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ import org.springframework.web.multipart.MultipartFile
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import springfox.documentation.builders.ApiInfoBuilder
import springfox.documentation.builders.RequestHandlerSelectors.basePackage
import springfox.documentation.schema.AlternateTypeRules.newRule
import springfox.documentation.service.Contact
import springfox.documentation.service.SecurityScheme
import springfox.documentation.spi.DocumentationType.SWAGGER_2
import springfox.documentation.spi.service.contexts.SecurityContext
import springfox.documentation.spring.web.plugins.Docket
import kotlin.coroutines.Continuation
Expand All @@ -37,11 +39,19 @@ import kotlin.coroutines.Continuation
* @author sokomishalov
*/

const val SWAGGER_UI_PAGE = "swagger-ui.html"
const val SWAGGER_UI_PAGE = "/swagger-ui/"
const val REDIRECT_TO_SWAGGER = "redirect:${SWAGGER_UI_PAGE}"
private val DEFAULT_AUTHOR = Contact("Sokolov Mikhael", "https://sokomishalov.github.io/about-me", "[email protected]")
private val TYPE_RESOLVER = TypeResolver()

inline fun <reified T : Any> initDocket(): Docket {
return Docket(SWAGGER_2)
.select()
.apis(basePackage(T::class.java.`package`.name))
.paths { true }
.build()
}

fun Docket.customize(
securityContext: SecurityContext? = null,
securityScheme: SecurityScheme? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("unused")
@file:Suppress(
"unused",
"NOTHING_TO_INLINE"
)

package ru.sokomishalov.commons.spring.web

Expand All @@ -27,7 +30,7 @@ import org.springframework.http.ResponseEntity
* @author sokomishalov
*/

inline fun <reified T> T?.toResponseEntity(): ResponseEntity<T> = when {
inline fun <T> T?.toResponseEntity(): ResponseEntity<T> = when {
this == null -> ResponseEntity.ok().build()
else -> ResponseEntity.ok(this)
}
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
<packaging>pom</packaging>

<properties>
<revision>1.1.15</revision>
<revision>1.1.16</revision>
<java.version>1.8</java.version>
<kotlin.version>1.3.72</kotlin.version>
<kotlinx-coroutines.version>1.3.7</kotlinx-coroutines.version>
<jackson.version>2.11.0</jackson.version>
<reactor.version>3.3.6.RELEASE</reactor.version>
<reactor-netty.version>0.9.8.RELEASE</reactor-netty.version>
<jackson.version>2.11.1</jackson.version>
<reactor.version>3.3.7.RELEASE</reactor.version>
<reactor-netty.version>0.9.9.RELEASE</reactor-netty.version>
<javax-servlet-api.version>4.0.1</javax-servlet-api.version>
<slf4j.version>1.7.30</slf4j.version>
<logback.version>1.2.3</logback.version>
<spring.boot.version>2.3.0.RELEASE</spring.boot.version>
<spring.boot.version>2.3.1.RELEASE</spring.boot.version>
<spring.version>5.2.7.RELEASE</spring.version>
<springfox.version>2.9.2</springfox.version>
<springfox.version>3.0.0</springfox.version>
</properties>

<modules>
Expand Down

0 comments on commit 0f2c48e

Please sign in to comment.