CRUD Sample App for Ant Media Server
In this sample application we created a custom REST API that makes CRUD operations on CRUDUser structure over Mongo DB. We wanted to show how you can make some server side modifications in your custom application running on top of Ant Media Server.
Here we added the followings different than default StreamApp provided by Ant Media Server:
io.antmedia.restpackage. Naming is important because Spring checks that directory to deploy components. In this package we createdCRUDService.javaclass which provides REST API.io.antmedia.pluginpackage. Naming is important because Spring checks that directory to deploy components. In this package we createdCRUDMain.javaclass which is can be considered as the entry point for our application. We can initialize everything necessary for our application.io.antmedia.dbpackage. In it we haveCRUDMongoStoreclass which modifies the Mongo DB. Also we haveCRUDUserclass that is the structure on which we make CRUD operations.
- clone the project
git clone https://github.com/burak-58/CRUDSampleApp.git
- in the project folder build it:
mvn clean install -DskipTests -Dgpg.skip=true
-
Install the war file created in
targetdirectory as a new application. -
Call the REST methos for:
CREATE:
curl -i -X POST -H "Accept: Application/json" -H "Content-Type: application/json" "http://localhost:5080/MyCRUDApp/rest/v1/sample/user" -d '{"name":"burak", "email":"[email protected]"}'READ:
curl -i -X GET -H "Accept: Application/json" -H "Content-Type: application/json" "http://localhost:5080/MyCRUDApp/rest/v1/sample/user/burak"'UPDATE:
curl -i -X PUT -H "Accept: Application/json" -H "Content-Type: application/json" "http://localhost:5080/MyCRUDApp/rest/v1/sample/user/burak" -d '{"email":"[email protected]"}''DELETE:
curl -i -X DELETE -H "Accept: Application/json" -H "Content-Type: application/json" "http://localhost:5080/MyCRUDApp/rest/v1/sample/user/burak"