1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-30 18:44:35 +01:00

remove unneeded methods

This commit is contained in:
Nikolay Kim 2019-03-07 15:51:24 -08:00
parent 88e5059910
commit eef687ec80
4 changed files with 19 additions and 34 deletions

View File

@ -27,7 +27,7 @@ pub use actix_web_codegen::*;
// re-export for convenience // re-export for convenience
pub use actix_http::Response as HttpResponse; pub use actix_http::Response as HttpResponse;
pub use actix_http::{body, error, http, Error, HttpMessage, ResponseError, Result}; pub use actix_http::{error, http, Error, HttpMessage, ResponseError, Result};
pub use crate::app::App; pub use crate::app::App;
pub use crate::extract::FromRequest; pub use crate::extract::FromRequest;
@ -154,37 +154,42 @@ pub mod web {
Scope::new(path) Scope::new(path)
} }
/// Create **route** without configuration. /// Create *route* without configuration.
pub fn route<P: 'static>() -> Route<P> { pub fn route<P: 'static>() -> Route<P> {
Route::new() Route::new()
} }
/// Create **route** with `GET` method guard. /// Create *route* with `GET` method guard.
pub fn get<P: 'static>() -> Route<P> { pub fn get<P: 'static>() -> Route<P> {
Route::get() Route::new().method(Method::GET)
} }
/// Create **route** with `POST` method guard. /// Create *route* with `POST` method guard.
pub fn post<P: 'static>() -> Route<P> { pub fn post<P: 'static>() -> Route<P> {
Route::post() Route::new().method(Method::POST)
} }
/// Create **route** with `PUT` method guard. /// Create *route* with `PUT` method guard.
pub fn put<P: 'static>() -> Route<P> { pub fn put<P: 'static>() -> Route<P> {
Route::put() Route::new().method(Method::PUT)
} }
/// Create **route** with `DELETE` method guard. /// Create *route* with `PATCH` method guard.
pub fn patch<P: 'static>() -> Route<P> {
Route::new().method(Method::PATCH)
}
/// Create *route* with `DELETE` method guard.
pub fn delete<P: 'static>() -> Route<P> { pub fn delete<P: 'static>() -> Route<P> {
Route::delete() Route::new().method(Method::DELETE)
} }
/// Create **route** with `HEAD` method guard. /// Create *route* with `HEAD` method guard.
pub fn head<P: 'static>() -> Route<P> { pub fn head<P: 'static>() -> Route<P> {
Route::new().method(Method::HEAD) Route::new().method(Method::HEAD)
} }
/// Create **route** and add method guard. /// Create *route* and add method guard.
pub fn method<P: 'static>(method: Method) -> Route<P> { pub fn method<P: 'static>(method: Method) -> Route<P> {
Route::new().method(method) Route::new().method(method)
} }

View File

@ -291,7 +291,7 @@ mod tests {
use actix_service::Service; use actix_service::Service;
use bytes::Bytes; use bytes::Bytes;
use crate::body::{Body, ResponseBody}; use crate::dev::{Body, ResponseBody};
use crate::http::StatusCode; use crate::http::StatusCode;
use crate::test::{init_service, TestRequest}; use crate::test::{init_service, TestRequest};
use crate::{web, App}; use crate::{web, App};

View File

@ -60,26 +60,6 @@ impl<P: 'static> Route<P> {
} }
} }
/// Create new `GET` route.
pub fn get() -> Route<P> {
Route::new().method(Method::GET)
}
/// Create new `POST` route.
pub fn post() -> Route<P> {
Route::new().method(Method::POST)
}
/// Create new `PUT` route.
pub fn put() -> Route<P> {
Route::new().method(Method::PUT)
}
/// Create new `DELETE` route.
pub fn delete() -> Route<P> {
Route::new().method(Method::DELETE)
}
pub(crate) fn finish(self) -> Self { pub(crate) fn finish(self) -> Self {
*self.config_ref.borrow_mut() = self.config.storage.clone(); *self.config_ref.borrow_mut() = self.config.storage.clone();
self self

View File

@ -451,7 +451,7 @@ mod tests {
use actix_service::Service; use actix_service::Service;
use bytes::Bytes; use bytes::Bytes;
use crate::body::{Body, ResponseBody}; use crate::dev::{Body, ResponseBody};
use crate::http::{Method, StatusCode}; use crate::http::{Method, StatusCode};
use crate::test::{block_on, init_service, TestRequest}; use crate::test::{block_on, init_service, TestRequest};
use crate::{guard, web, App, HttpRequest, HttpResponse}; use crate::{guard, web, App, HttpRequest, HttpResponse};