Setup scaffold of call routing
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
pub mod database;
|
||||
pub mod httapi;
|
||||
pub mod schema;
|
||||
|
||||
use std::ops::Deref;
|
||||
use std::str::FromStr;
|
||||
use xml_builder::{XMLBuilder, XMLElement, XMLVersion};
|
||||
use actix_web::{web, App,
|
||||
HttpResponse,
|
||||
HttpServer,
|
||||
@@ -29,34 +29,11 @@ struct JsonDid {
|
||||
}
|
||||
|
||||
async fn route_did(data: web::Form<RouteData>) -> impl Responder {
|
||||
let _dest_did = data.dest_did.clone();
|
||||
let mut xml = XMLBuilder::new()
|
||||
.version(XMLVersion::XML1_1)
|
||||
.encoding("UTF-8".into())
|
||||
.build();
|
||||
|
||||
let mut doc = XMLElement::new("document");
|
||||
doc.add_attribute("type", "xml/freeswitch-httapi");
|
||||
|
||||
let params = XMLElement::new("params");
|
||||
let mut work = XMLElement::new("work");
|
||||
|
||||
let mut playback = XMLElement::new("playback");
|
||||
playback.add_attribute("name", "exten");
|
||||
playback.add_attribute("file", "ivr/ivr-welcome_to_freeswitch.wav");
|
||||
work.add_child(playback).unwrap();
|
||||
|
||||
doc.add_child(params).unwrap();
|
||||
doc.add_child(work).unwrap();
|
||||
|
||||
xml.set_root_element(doc);
|
||||
|
||||
let mut writer: Vec<u8> = Vec::new();
|
||||
xml.generate(&mut writer).unwrap();
|
||||
|
||||
let did = data.dest_did.clone();
|
||||
let xml = httapi::route_call(did);
|
||||
HttpResponse::Ok()
|
||||
.content_type(ContentType::xml())
|
||||
.body(writer)
|
||||
.body(xml)
|
||||
}
|
||||
|
||||
async fn did_post(d: web::Json<JsonDid>) -> impl Responder {
|
||||
|
||||
Reference in New Issue
Block a user