From 0a8af55f05d88551075da16579bb632289a88c7a Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Thu, 26 Dec 2019 16:18:15 -0500 Subject: [PATCH] define type for state data --- src/routes.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/routes.rs b/src/routes.rs index d07db7f..f094ded 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -12,6 +12,8 @@ use serde::Deserialize; use std::collections::HashMap; use std::sync::{Arc, RwLock}; +type StateData = Data>>; + /// https://url.spec.whatwg.org/#fragment-percent-encode-set const FRAGMENT_ENCODE_SET: &AsciiSet = &CONTROLS .add(b' ') @@ -43,7 +45,7 @@ pub struct SearchQuery { #[get("/hop")] pub async fn hop( - data: Data>>, + data: StateData, req: HttpRequest, query: Query, ) -> impl Responder { @@ -121,10 +123,7 @@ fn resolve_hop( } #[get("/")] -pub async fn index( - data: Data>>, - req: HttpRequest, -) -> impl Responder { +pub async fn index(data: StateData, req: HttpRequest) -> impl Responder { let data = data.read().unwrap(); HttpResponse::Ok().body( req @@ -139,10 +138,7 @@ pub async fn index( } #[get("/bunbunsearch.xml")] -pub async fn opensearch( - data: Data>>, - req: HttpRequest, -) -> impl Responder { +pub async fn opensearch(data: StateData, req: HttpRequest) -> impl Responder { let data = data.read().unwrap(); HttpResponse::Ok() .header(