mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-20 16:50:39 +00:00
added redirect verb
This commit is contained in:
@@ -39,6 +39,9 @@ function makeTask(logger, obj) {
|
||||
case TaskName.Listen:
|
||||
const TaskListen = require('./listen');
|
||||
return new TaskListen(logger, data);
|
||||
case TaskName.Redirect:
|
||||
const TaskRedirect = require('./redirect');
|
||||
return new TaskRedirect(logger, data);
|
||||
}
|
||||
|
||||
// should never reach
|
||||
|
||||
23
lib/tasks/redirect.js
Normal file
23
lib/tasks/redirect.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const Task = require('./task');
|
||||
const {TaskName} = require('../utils/constants');
|
||||
|
||||
/**
|
||||
* Redirects to a new application
|
||||
*/
|
||||
class TaskRedirect extends Task {
|
||||
constructor(logger, opts) {
|
||||
super(logger, opts);
|
||||
|
||||
this.action = this.data.action;
|
||||
this.method = this.data.method || 'POST';
|
||||
}
|
||||
|
||||
get name() { return TaskName.Redirect; }
|
||||
|
||||
async exec(cs) {
|
||||
super.exec(cs);
|
||||
await this.performAction(this.method, this.auth);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TaskRedirect;
|
||||
@@ -102,6 +102,19 @@
|
||||
"url"
|
||||
]
|
||||
},
|
||||
"redirect": {
|
||||
"properties": {
|
||||
"action": "string",
|
||||
"method": {
|
||||
"type": "string",
|
||||
"enum": ["GET", "POST"]
|
||||
},
|
||||
"auth": "#auth"
|
||||
},
|
||||
"required": [
|
||||
"action"
|
||||
]
|
||||
},
|
||||
"transcribe": {
|
||||
"properties": {
|
||||
"transcriptionCallback": "string",
|
||||
|
||||
@@ -25,6 +25,10 @@ class Task extends Emitter {
|
||||
return this.cs;
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
async exec(cs) {
|
||||
this.cs = cs;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user