Skip to content

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Nov 12, 2020
1 parent d8763bb commit b0eafba
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/cookies/middleware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) struct CookiesMiddleware;

impl CookiesMiddleware {
/// Creates a new `CookiesMiddleware`.
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Self::default()
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ where
}
}

pub struct MiddlewareEndpoint<E, State> {
pub(crate) struct MiddlewareEndpoint<E, State> {
endpoint: E,
middleware: Vec<Arc<dyn Middleware<State>>>,
}
Expand Down Expand Up @@ -96,7 +96,7 @@ where
State: Clone + Send + Sync + 'static,
E: Endpoint<State>,
{
pub fn wrap_with_middleware(ep: E, middleware: &[Arc<dyn Middleware<State>>]) -> Self {
pub(crate) fn wrap_with_middleware(ep: E, middleware: &[Arc<dyn Middleware<State>>]) -> Self {
Self {
endpoint: ep,
middleware: middleware.to_vec(),
Expand Down
2 changes: 1 addition & 1 deletion src/fs/serve_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use async_std::path::PathBuf as AsyncPathBuf;
use std::ffi::OsStr;
use std::path::{Path, PathBuf};

pub struct ServeDir {
pub(crate) struct ServeDir {
prefix: String,
dir: PathBuf,
}
Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
#![cfg_attr(feature = "docs", feature(doc_cfg))]
#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(future_incompatible, missing_debug_implementations, nonstandard_style)]
#![warn(missing_docs, missing_doc_code_examples, unreachable_pub)]
#![warn(missing_docs, unreachable_pub)]
#![doc(html_favicon_url = "https://yoshuawuyts.com/assets/http-rs/favicon.ico")]
#![doc(html_logo_url = "https://yoshuawuyts.com/assets/http-rs/logo-rounded.png")]

Expand All @@ -69,12 +69,11 @@ mod request;
mod response;
mod response_builder;
mod route;
mod server;

#[cfg(not(feature = "__internal__bench"))]
mod router;
#[cfg(feature = "__internal__bench")]
// Expose the router for benchmarking only.
#[doc(hidden)]
pub mod router;
mod server;

pub mod convert;
pub mod listener;
Expand Down
3 changes: 2 additions & 1 deletion src/listener/to_listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ use async_std::io;
/// ```
/// # Other implementations
/// See below for additional provided implementations of ToListener.

pub trait ToListener<State: Clone + Send + Sync + 'static> {
/// What listener are we converting into?
type Listener: Listener<State>;

/// Transform self into a
/// [`Listener`](crate::listener::Listener). Unless self is
/// already bound/connected to the underlying io, converting to a
Expand Down
12 changes: 6 additions & 6 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@ use crate::{Request, Response, StatusCode};
/// Internally, we have a separate state machine per http method; indexing
/// by the method first allows the table itself to be more efficient.
#[allow(missing_debug_implementations)]
pub struct Router<State> {
pub(crate) struct Router<State> {
method_map: HashMap<http_types::Method, MethodRouter<Box<DynEndpoint<State>>>>,
all_method_router: MethodRouter<Box<DynEndpoint<State>>>,
}

/// The result of routing a URL
#[allow(missing_debug_implementations)]
pub struct Selection<'a, State> {
pub(crate) struct Selection<'a, State> {
pub(crate) endpoint: &'a DynEndpoint<State>,
pub(crate) params: Params,
}

impl<State: Clone + Send + Sync + 'static> Router<State> {
pub fn new() -> Self {
pub(crate) fn new() -> Self {
Router {
method_map: HashMap::default(),
all_method_router: MethodRouter::new(),
}
}

pub fn add(&mut self, path: &str, method: http_types::Method, ep: Box<DynEndpoint<State>>) {
pub(crate) fn add(&mut self, path: &str, method: http_types::Method, ep: Box<DynEndpoint<State>>) {
self.method_map
.entry(method)
.or_insert_with(MethodRouter::new)
.add(path, ep)
}

pub fn add_all(&mut self, path: &str, ep: Box<DynEndpoint<State>>) {
pub(crate) fn add_all(&mut self, path: &str, ep: Box<DynEndpoint<State>>) {
self.all_method_router.add(path, ep)
}

pub fn route(&self, path: &str, method: http_types::Method) -> Selection<'_, State> {
pub(crate) fn route(&self, path: &str, method: http_types::Method) -> Selection<'_, State> {
if let Some(Match { handler, params }) = self
.method_map
.get(&method)
Expand Down
6 changes: 3 additions & 3 deletions src/security/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pub struct CorsMiddleware {
max_age: HeaderValue,
}

pub const DEFAULT_MAX_AGE: &str = "86400";
pub const DEFAULT_METHODS: &str = "GET, POST, OPTIONS";
pub const WILDCARD: &str = "*";
pub(crate) const DEFAULT_MAX_AGE: &str = "86400";
pub(crate) const DEFAULT_METHODS: &str = "GET, POST, OPTIONS";
pub(crate) const WILDCARD: &str = "*";

impl CorsMiddleware {
/// Creates a new Cors middleware.
Expand Down

0 comments on commit b0eafba

Please sign in to comment.