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
use std::path::PathBuf;

use actix_web::{App, dev::{ServiceFactory, ServiceRequest}, Error};
use easy_ext::ext;

use crate::integration::actix::{
    command_handler::command,
    notification_result_handler::notification_callback,
    status_handler::status
};

#[cfg(feature = "actix-web")]
#[ext(IActixHandlersExt)]
#[async_trait_with_sync::async_trait]
pub impl<T> App<T>
where
    T: ServiceFactory<ServiceRequest, Config = (), Error = Error, InitError = ()>,
{
    fn add_botx_api_handlers(self) -> App<T> {
        self.service(command)
            .service(notification_callback)
            .service(status)
    }

    fn add_smartapp_static_files(self, static_files_path: impl Into<PathBuf>) -> App<T> {
        self.service(actix_files::Files::new("/smartapp_files/static", static_files_path).show_files_listing())
    }
}