-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
37 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
use serde::Deserialize; | ||
use spring::config::Configurable; | ||
|
||
#[derive(Clone, Deserialize, Configurable)] | ||
#[config_prefix = "ip2region"] | ||
pub struct Ip2RegionConfig { | ||
pub db_path: String, | ||
} | ||
|
||
fn default_db_path() -> String { | ||
"./data/ip2region.xdb".to_string() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use crate::config::ip2region::Ip2RegionConfig; | ||
use spring::{app::AppBuilder, async_trait, config::ConfigRegistry, plugin::Plugin}; | ||
use xdb::searcher_init; | ||
|
||
pub struct Ip2RegionPlugin; | ||
|
||
#[async_trait] | ||
impl Plugin for Ip2RegionPlugin { | ||
async fn build(&self, app: &mut AppBuilder) { | ||
let config = app | ||
.get_config::<Ip2RegionConfig>() | ||
.expect("ip2region config is invalid"); | ||
searcher_init(Some(config.db_path)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod akismet; | ||
pub mod uaparser; | ||
pub mod uaparser; | ||
pub mod ip2region; |