Created
May 25, 2020 18:04
-
-
Save dunglas/788b70312231d24e46d7632c634784f5 to your computer and use it in GitHub Desktop.
URI Template test in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.demo; | |
import java.util.Map; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import org.springframework.web.util.UriTemplate; | |
@SpringBootApplication | |
@RestController | |
public class DemoApplication { | |
public static void main(String[] args) { | |
SpringApplication.run(DemoApplication.class, args); | |
} | |
@GetMapping("/") | |
public String uriTemplate() { | |
UriTemplate ut = new UriTemplate("https://example.net/{ip}"); | |
Map<String, String> m = ut.match("https://example.net/2001:db8::35"); | |
return String.format("ip := %s", m.get("ip")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment