botx_api_framework/extensions/
actix.rs

1use std::path::PathBuf;
2
3use actix_web::{App, dev::{ServiceFactory, ServiceRequest}, Error};
4use easy_ext::ext;
5
6use crate::integration::actix::{
7    command_handler::command,
8    notification_result_handler::notification_callback,
9    status_handler::status
10};
11
12#[cfg(feature = "actix-web")]
13#[ext(IActixHandlersExt)]
14#[async_trait_with_sync::async_trait]
15pub impl<T> App<T>
16where
17    T: ServiceFactory<ServiceRequest, Config = (), Error = Error, InitError = ()>,
18{
19    fn add_botx_api_handlers(self) -> App<T> {
20        self.service(command)
21            .service(notification_callback)
22            .service(status)
23    }
24
25    fn add_smartapp_static_files(self, static_files_path: impl Into<PathBuf>) -> App<T> {
26        self.service(actix_files::Files::new("/smartapp_files/static", static_files_path).show_files_listing())
27    }
28}