The code is designed around nothing but boring guidelines for a Spring application. The upper layer consists of controllers. They are annotated with @RestController and provide REST endpoints made available as @RequestMapping -annotated methods. In turn, those methods call the second layer implemented as services.

As seen above, the filter pattern itself is the last path segment. It’s mapped to a method parameter via the @PathVariable annotation.

@RestController class JvmPropsController ( private val service : JvmPropsService ) { @RequestMapping ( path = arrayOf ( "/jvmprops/{filter}" ), method = arrayOf ( GET )) fun readJvmProps ( @PathVariable filter : String ): Map < String , * > = service . getJvmProps () }

To effectively implement filtering, the path segment allows star characters. In Java however, string matching is achieved via regular expression. It’s then mandatory to "translate" the simple calling pattern to a full-fledge regexp. Regarding the above example, not only the dot character needs to be escaped - from . but to \\. , but the star character needs to be translated accordingly - from to . :

val regex = filter . replace ( "." , "\\." ). replace ( "*" , ".*" )