rename wrap annotations
This commit is contained in:
parent
109ff1675e
commit
6d14e19aa1
|
|
@ -8,17 +8,17 @@ import org.springframework.http.server.ServerHttpRequest
|
|||
import org.springframework.http.server.ServerHttpResponse
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice
|
||||
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice
|
||||
import ru.touchin.wrapper.annotations.NoWrapResponse
|
||||
import ru.touchin.wrapper.annotations.WrapResponse
|
||||
import ru.touchin.wrapper.annotations.NoResponseWrap
|
||||
import ru.touchin.wrapper.annotations.ResponseWrap
|
||||
import ru.touchin.wrapper.components.ResponseBodyWrapper
|
||||
|
||||
@RestControllerAdvice(annotations = [WrapResponse::class])
|
||||
@RestControllerAdvice(annotations = [ResponseWrap::class])
|
||||
class WrapResponseAdvice(
|
||||
private val responseWrapper: ResponseBodyWrapper
|
||||
): ResponseBodyAdvice<Any> {
|
||||
|
||||
override fun supports(returnType: MethodParameter, converterType: Class<out HttpMessageConverter<*>>): Boolean {
|
||||
return !returnType.hasMethodAnnotation(NoWrapResponse::class.java)
|
||||
return !returnType.hasMethodAnnotation(NoResponseWrap::class.java)
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package ru.touchin.wrapper.annotations
|
||||
|
||||
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CLASS])
|
||||
annotation class NoWrapResponse
|
||||
annotation class NoResponseWrap
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ru.touchin.wrapper.annotations
|
||||
|
||||
@Target(allowedTargets = [AnnotationTarget.FUNCTION, AnnotationTarget.CLASS])
|
||||
annotation class WrapResponse
|
||||
annotation class ResponseWrap
|
||||
|
|
@ -15,11 +15,11 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
|||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import ru.touchin.wrapper.annotations.NoWrapResponse
|
||||
import ru.touchin.wrapper.annotations.WrapResponse
|
||||
import ru.touchin.wrapper.annotations.NoResponseWrap
|
||||
import ru.touchin.wrapper.annotations.ResponseWrap
|
||||
|
||||
@RestController
|
||||
@WrapResponse
|
||||
@ResponseWrap
|
||||
@RequestMapping("/wrapper")
|
||||
class WrapperController {
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ class WrapperController {
|
|||
return mapOf("wrap" to "yes")
|
||||
}
|
||||
|
||||
@NoWrapResponse
|
||||
@NoResponseWrap
|
||||
@GetMapping("/no-wrap")
|
||||
fun noWrap(): Map<String, String> {
|
||||
return mapOf("wrap" to "no")
|
||||
|
|
|
|||
Loading…
Reference in New Issue