Skip to content

Instantly share code, notes, and snippets.

@dunglas
Created May 25, 2020 18:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
URI Template test in Java
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