#Java Rest-api Framework from CS682 ##Instructions
- download the source code and build an artifact
- include the jar into your project as a dependency
- you are on your way to build a restful api
##Examples ###Main class Has to be in the root package
public class Main {
public static void main(String[] args) throws Exception {
new Server(Main.class, port-number, thread-number).start();
}
}
###Controllers
@RestController("test")
public class TestController {
@RequestMapping(value = "/", method = HttpMethod.GET)
public HttpResponse test(HttpRequest httpRequest) {
HttpResponse httpResponse = new HttpResponse();
httpResponse.setBody("123");
return httpResponse;
}
}
###Configurations
@Configuration
public class Configuration {
@ConfigurationMethod
public void configure() {
System.out.println("hello world");
}
}
###Test
- run the main method
- curl http://localhost:8080/test
###Dependencies
- GSON for json parsing