基于Groovy + SpringMVC 的一套Rest JSON API
jopen
10年前
CoC 理念的一套HTTP JSON API框架,基于SpringMVC 和 Groovy,内置了 MongoDB CRUD模版(JSON和MongoDB天然好基友)!!
Overview
- Write Your Controller In Groovy
@Rest class MyController extends ControllerSupport7 { def hello(HttpServletRequest req) { [code: 1, data: "Hello, ${req['name']} !"] } }
- Open http://localhost:8080/
my
/hello
?name=World
{"code":1,"data":"Hello, World !"}
That's ALL !!!
- the main Convention
As you see,my
is the Controller Name (first lowercase) and hello
is the method Name.This is The main Convention
.
Don't forget the @Rest
annotation on the controller.
@Rest
=@Controller
(SpringMVC) +@CompileStatic
(Groovy)
@RestWithSesson
=@Controller
+@CompileStatic
+@Interceptors