-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathsample-controller.js
37 lines (30 loc) · 1.3 KB
/
sample-controller.js
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
require('./helpers')();
/**
* SampleController
*/
class SampleController {
async index(req) {
let res = {
res: '<html><body><a href="https://github.com/anderly/cloudflare-worker-routing/blob/master/src/sample-controller.js#L8-L14" target="_blank" title="See the source that generated this on GitHub">SampleController@index</a></body></html>',
headers: { 'content-type': 'text/html' },
};
return response(res);
}
async show(req) {
let res = {
res: '<html><body><a href="https://github.com/anderly/cloudflare-worker-routing/blob/master/src/sample-controller.js#L16-L22" target="_blank" title="See the source that generated this on GitHub">SampleController@show</a>: id=' + req.params.id + '</body></html>',
headers: { 'content-type': 'text/html' },
};
return response(res);
}
async store(req) {
return response('SampleController@store: Posted Data = ' + Object.keys(req.body).map(key => key + '=' + encodeURIComponent(req.body[key])).join('&'));
}
async update(req) {
return response('SampleController@update: id=' + req.params.id);
}
async destroy(req) {
return response('SampleController@destroy: id=' + req.params.id);
}
}
export default new SampleController();