rename version annotations
This commit is contained in:
parent
b903289b21
commit
06e692ea9b
|
|
@ -0,0 +1,6 @@
|
|||
package ru.touchin.version.annotations
|
||||
|
||||
@Target(allowedTargets = [AnnotationTarget.CLASS])
|
||||
internal annotation class Versioned(
|
||||
val value: String = ""
|
||||
)
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
package ru.touchin.version.annotations
|
||||
|
||||
@Versioned("/api/v\${api.version}")
|
||||
@Target(allowedTargets = [AnnotationTarget.CLASS])
|
||||
annotation class VersionedApi(
|
||||
val value: String = ""
|
||||
)
|
||||
annotation class VersionedApi
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
package ru.touchin.version.annotations
|
||||
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@VersionedApi("/api/v\${api.version}")
|
||||
@Target(allowedTargets = [AnnotationTarget.CLASS])
|
||||
annotation class VersionedRestController
|
||||
|
|
@ -3,7 +3,7 @@ package ru.touchin.version.mapping
|
|||
import org.springframework.core.annotation.AnnotatedElementUtils
|
||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo
|
||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
|
||||
import ru.touchin.version.annotations.VersionedApi
|
||||
import ru.touchin.version.annotations.Versioned
|
||||
import java.lang.reflect.Method
|
||||
|
||||
class VersionedRequestMappingHandlerMapping : RequestMappingHandlerMapping() {
|
||||
|
|
@ -12,7 +12,7 @@ class VersionedRequestMappingHandlerMapping : RequestMappingHandlerMapping() {
|
|||
val mappingResult = super.getMappingForMethod(method, handlerType)
|
||||
?: return null
|
||||
|
||||
val versionedAnnotation = AnnotatedElementUtils.findMergedAnnotation(handlerType, VersionedApi::class.java)
|
||||
val versionedAnnotation = AnnotatedElementUtils.findMergedAnnotation(handlerType, Versioned::class.java)
|
||||
?: return mappingResult
|
||||
|
||||
val versionPath = resolveEmbeddedValuesInPatterns(
|
||||
|
|
|
|||
|
|
@ -17,9 +17,10 @@ import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
|
|||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import ru.touchin.version.annotations.VersionedRestController
|
||||
import ru.touchin.version.annotations.VersionedApi
|
||||
|
||||
@VersionedRestController
|
||||
@VersionedApi
|
||||
@RestController
|
||||
@RequestMapping("/app")
|
||||
class VersionController {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue