Solon

Solon Rest Api 开发

参考示例:

@Mapping("books")
@Controller
public class Demo{
    
    //查看所有图书:GET http://demo.com/books
    @Get
    @Mapping
    public String all(){
        return "all";
    }
    
    //查看一本图书:GET http://demo.com/books?id=1
    @Get
    @Mapping
    public String one(long id){
        return "one";
    }
    
    //新增一本书:POST http://demo.com/books
    //Data: name=shuxue
    @Post
    @Mapping
    public String add(Book book){
        return "add";
    }
    
    //修改一本书:PUT http://demo.com/books 
    //Data:id=1,name=shuxue
    @Put
    @Mapping
    public String update(long id=1, String name){
        return "update";
    }
    
    //查看一本图书:删除一本书:DELETE http://demo.com/books
    //Data:id=1
    @Delete
    @Mapping
    public String del(long id){
        return "del";
    }
}