bios_basic/lib.rs
1//! Basic library for BIOS
2//!
3//! BIOS的基础库
4//!
5//! This library provides the following functions:
6//! 1. RBUM (Resource-Based Unified Model) model and implementation of common operations.
7//! 1. SPI (Service Provider Interface) model and implementation of common operations.
8//! 1. Common enumeration types.
9//! 1. Common utility functions.
10//! 1. Basic test support.
11//!
12//! 此类库提供了下功能:
13//! 1. RBUM(基于资源的统一模型)模型及公共操作的实现
14//! 1. SPI(服务提供接口)模型及公共操作的实现
15//! 1. 通用枚举类型
16//! 1. 通用工具函数
17//! 1. 基础的测试支持
18extern crate lazy_static;
19
20pub mod dto;
21pub mod enumeration;
22pub mod helper;
23pub mod process;
24pub mod rbum;
25pub mod spi;
26#[cfg(feature = "test")]
27pub mod test;
28
29pub use enumeration::ApiTag;
30use tardis::{TardisFuns, TardisFunsInst};
31
32/// Extractor for ``TardisFunInst``
33///
34/// 提取 ``TardisFunsInst``
35pub trait TardisFunInstExtractor {
36 fn tardis_fun_inst(&self) -> TardisFunsInst;
37}
38
39/// Extract ``TardisFunInst`` from request path
40///
41/// 从请求路径中自动提取 ``TardisFunInst``
42///
43/// Get the first path segment from the request path as the service domain.
44/// If there is a configuration parameter ``csm.X`` with the same name as the service domain, use this configuration parameter,
45/// otherwise use the default configuration parameter.
46///
47/// 从请求路径中找到第一个路径段作为服务域名,如果存在与该服务域名同名的配置参数 ``csm.X``, 则使用该配置参数,否则使用默认配置参数.
48
49impl TardisFunInstExtractor for tardis::web::poem::Request {
50 fn tardis_fun_inst(&self) -> TardisFunsInst {
51 let serv_domain = self.original_uri().path().split('/').collect::<Vec<&str>>()[1];
52 TardisFuns::inst_with_db_conn(serv_domain.to_string(), None)
53 }
54}