Check out AndServer project available on github. Its a Web server and Web framework of Android platform. It provides annotations like SpringMVC.
@RestController
@RequestMapping(path = "/user")
public class UserController {
@PostMapping("/login")
public String login(@RequestParam("account") String account,
@RequestParam("password") String password) {
...
return "Successful.";
}
@GetMapping(path = "/{userId}")
public User info(@PathVariable("userId") String userId,
@QueryParam("fields") String fields) {
User user = findUserById(userId, fields);
...
return user;
}
@PutMapping(path = "/{userId}")
public void modify(@PathVariable("userId") String userId
@RequestParam("age") int age) {
...
}
}
Simple deployment
Server server = AndServer.webServer(context)
.port(8080)
.timeout(10, TimeUnit.SECONDS)
.build();
// startup the server.
server.startup();
...
// shutdown the server.
server.shutdown();