Browse Source

Cargo Clippy linting suggestions

develop
Drew Short 6 years ago
parent
commit
6e92cabcbe
  1. 10
      src/main.rs
  2. 6
      src/server/api.rs
  3. 2
      src/server/router.rs

10
src/main.rs

@ -20,14 +20,14 @@ mod config;
mod server;
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
const DEFAULT_HOST: &'static str = "localhost";
const VERSION: &str = env!("CARGO_PKG_VERSION");
const DEFAULT_HOST: &str = "localhost";
const DEFAULT_PORT: i16 = 8080;
lazy_static! {
static ref DEFAULT_PORT_STR: String = String::from(DEFAULT_PORT.to_string());
static ref DEFAULT_PORT_STR: String = DEFAULT_PORT.to_string();
static ref DEFAULT_WORKERS: usize = num_cpus::get();
static ref DEFAULT_WORKERS_STR: String = String::from(DEFAULT_WORKERS.to_string());
static ref DEFAULT_WORKERS_STR: String = DEFAULT_WORKERS.to_string();
}
fn main() {
@ -60,7 +60,7 @@ fn main() {
host, port, workers, config_path
);
let actix_server = actix_web::server::new(|| server::router::create())
let actix_server = actix_web::server::new(server::router::create)
.workers(workers)
.bind(format!("{}:{}", host, port));

6
src/server/api.rs

@ -29,10 +29,10 @@ fn update_address(address: String) -> String {
fn parse_remote_info(remote_info: &str) -> Result<IpAddr, APIError> {
let mut remote_address = String::from(remote_info);
if remote_address.contains(":") {
let last_colon_index = remote_address.rfind(":").unwrap();
if remote_address.contains(':') {
let last_colon_index = remote_address.rfind(':').unwrap();
let _port = remote_address.split_off(last_colon_index);
if remote_address.starts_with("[") && remote_address.ends_with("]") {
if remote_address.starts_with('[') && remote_address.ends_with(']') {
remote_address = String::from(remote_address.trim_matches(|c| c == '[' || c == ']'))
}
match IpAddr::from_str(&remote_address) {

2
src/server/router.rs

@ -8,7 +8,7 @@ use crate::server;
pub fn create() -> App {
actix_web::App::new()
.middleware(Logger::default())
.scope("api/", |api_scope| server::api::route(api_scope))
.scope("api/", server::api::route)
.resource("/health", |r| {
r.method(http::Method::GET).with(server::healthcheck)
})

Loading…
Cancel
Save