8000 GitHub - htrucci/apiversion: Easier API Versioning Manage With @Annotation
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

htrucci/apiversion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apiversion

It Can ApiVersioning Easier With Annotation

Must Express Position of API Version With {version}

@RequestMapping("/service/api/{version}/")

It's Possible ApiVersioning Both Class Level RequestMapping And Method RequestMapping


@Controller
@RequestMapping("/service/api/")
public class ApiController {

  // /service/api/v2/test
  @ApiVersion(version = Version.V2)
	@RequestMapping(value = "/{version}/test", method = {RequestMethod.GET, RequestMethod.POST})
	public String testv2(HttpServletRequest httpReq, Model model) throws Exception{
		System.out.println("testv2");
		return "test";
	}
}

If You Declare Class And Method Both Then Class Declare is Ignored. Method Annotation is Priority First.


@Controller
@RequestMapping("/service/api/{version}/")
@ApiVersion(version = Version.V3)
public class ApiTobeController {

  // /service/api/v3/test
	@RequestMapping(value = "/test", method = {RequestMethod.GET, RequestMethod.POST})
	public String testv3(HttpServletRequest httpReq, Model model) throws Exception{
		return "test";
	}

  // /service/api/v4/test
  // /service/api/v5/test  
	@ApiVersion(version = {Version.V4, Version.V5})
	@RequestMapping(value = "/{version}/test", method = {RequestMethod.GET, RequestMethod.POST})
	public String testv45(HttpServletRequest httpReq, Model model) throws Exception{
		return "test";
	}
}

It's Possible Create Multiple Version UrlMapping


@ApiVersion(version = {Version.V4, Version.V5})
@RequestMapping(value = "/{version}/test", method = {RequestMethod.GET, RequestMethod.POST})
public String testv45(HttpServletRequest httpReq, Model model) throws Exception{
  return "test";
}

About

Easier API Versioning Manage With @annotation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0