-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCustomersScriptExample.cfc
More file actions
46 lines (33 loc) · 1.33 KB
/
Copy pathCustomersScriptExample.cfc
File metadata and controls
46 lines (33 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
component rest="true" restpath="/customers/script" Name="Customers"{
//GET Request to return customers
function get () access="remote" returntype="array" produces="application/json" httpmethod="GET" {
var customers = [];
customers[1] = "Brian";
customers[2] = "Caroline";
customers[3] = "Noah";
customers[4] = "Elijah";
customers[5] = "Maverick";
return customers;
}
//POST Request to write a new customer to the database
function post () access="remote" returntype="string" produces="application/json" httpmethod="POST" {
//do database insert and validation logic
//return a successful message in the response
var message = "Customer has been added.";
return message;
}
//PUT Request to edit a customer in the database
function put () access="remote" returntype="string" produces="application/json" httpmethod="PUT" {
//do database update and validation logic
//return a successful message in the response
var message = "Customer has been updated.";
return message;
}
//DELETE Request to remove a customer in the database
function delete () access="remote" returntype="string" produces="application/json" httpmethod="DELETE" {
//do database delete and validation logic
//return a successful message in the response
var message = "Customer has been deleted.";
return message;
}
}