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