1

I want implement an annotation in spring boot. It's required to get path variable and use in annotation.

@PostMapping("/v1/{id}")
    @HasZone(id = "#id")
    @ResponseStatus(HttpStatus.NO_CONTENT)
    fun createCompany( @PathVariable id: String) {
        ....
}
@Target(AnnotationTarget.FUNCTION)
annotation class HasZone(vararg val id: String)
@Before("@annotation(hasZone)")
    fun checkZonePermissions(hasZone: HasZone) {
        println(hasZone.id)
}

I get the parameter in PreAuthorize like this: #id. But in this function, name of the variable path to function as a string.

Where is the wrong thing to do? How can I fixed the problem?

mgh
  • 921
  • 3
  • 9
  • 37

0 Answers0