Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- component
- restpath = "test/people/"
- rest = true
- {
- remote void function create(
- required string first_name restargsource = "Form",
- required string last_name restargsource = "Form"
- )
- httpmethod = "POST"
- restpath = ""
- produces = "application/json"
- {
- // Simulate adding person to database.
- ArrayAppend(
- Application.people,
- { "first_name" = first_name, "last_name" = last_name }
- );
- // Simulate getting people from database.
- var people = Application.people;
- restSetResponse( {
- "status" = 201,
- "content" = SerializeJSON( people )
- } );
- }
- }
- httpService = new http(method = "POST", url = "https://localhost/rest/test/people");
- httpService.addParam( name = "first_name", type = "formfield", value = "Alice" );
- httpService.addParam( name = "last_name", type = "formfield", value = "Adams" );
- result = httpService.send().getPrefix();
- <cfscript>
- Application.people = [];
- people = new restmapping.test.People();
- people.create( "Alice", "Adams" );
- WriteDump( application.people );
- </cfscript>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement