SakaDream/actix-web-rest-api-with-jwt

Update to actix-web 4?

alloc33 opened this issue · 0 comments

I there any easy way to update it to actix-web 4?)

I got few error during the build:

error[E0432]: unresolved imports `actix_web::http::HeaderName`, `actix_web::http::HeaderValue`
 --> src/middleware/auth_middleware.rs:5:12
  |
5 |     http::{HeaderName, HeaderValue, Method},
  |            ^^^^^^^^^^  ^^^^^^^^^^^ no `HeaderValue` in `http`
  |            |
  |            no `HeaderName` in `http`

error[E0277]: the trait bound `fn() -> HttpResponse {ping}: Handler<_>` is not satisfied
   --> src/api/ping_controller.rs:4:4
    |
3   | #[get("/ping")]
    | --------------- required by a bound introduced by this call
4   | fn ping() -> HttpResponse {
    |    ^^^^ the trait `Handler<_>` is not implemented for `fn() -> HttpResponse {ping}`
    |
note: required by a bound in `Resource::<T>::to`
   --> /Users/nshv/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-4.2.1/src/resource.rs:224:12
    |
224 |         F: Handler<Args>,
    |            ^^^^^^^^^^^^^ required by this bound in `Resource::<T>::to`

error[E0277]: the trait bound `actix_web::dev::Response<_>: std::convert::From<BoxBody>` is not satisfied
   --> src/middleware/auth_middleware.rs:109:21
    |
108 |                   Ok(req.into_response(
    |                          ------------- required by a bound introduced by this call
109 | /                     HttpResponse::Unauthorized()
110 | |                         .json(ResponseBody::new(
111 | |                             constants::MESSAGE_INVALID_TOKEN,
112 | |                             constants::EMPTY,
113 | |                         ))
114 | |                         .into_body(),
    | |____________________________________^ the trait `std::convert::From<BoxBody>` is not implemented for `actix_web::dev::Response<_>`
    |
    = help: the following other types implement trait `std::convert::From<T>`:
              <actix_web::dev::Response<&'static [u8]> as std::convert::From<&'static [u8]>>
              <actix_web::dev::Response<&'static str> as std::convert::From<&'static str>>
              <actix_web::dev::Response<B> as std::convert::From<HttpResponse<B>>>
              <actix_web::dev::Response<B> as std::convert::From<ServiceResponse<B>>>
              <actix_web::dev::Response<BoxBody> as std::convert::From<&actix_http::ws::HandshakeError>>
              <actix_web::dev::Response<BoxBody> as std::convert::From<HttpResponseBuilder>>
              <actix_web::dev::Response<BoxBody> as std::convert::From<Infallible>>
              <actix_web::dev::Response<BoxBody> as std::convert::From<Result<I, E>>>
            and 13 others
    = note: required because of the requirements on the impl of `Into<actix_web::dev::Response<_>>` for `BoxBody`
note: required by a bound in `ServiceRequest::into_response`
   --> /Users/nshv/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-4.2.1/src/service.rs:156:32
    |
156 |     pub fn into_response<B, R: Into<Response<B>>>(self, res: R) -> ServiceResponse<B> {
    |                                ^^^^^^^^^^^^^^^^^ required by this bound in `ServiceRequest::into_response`

error[E0277]: the trait bound `Cors: actix_web::dev::Transform<actix_web::app_service::AppRouting, ServiceRequest>` is not satisfied
   --> src/main.rs:60:17
    |
59  |               .wrap(
    |                ---- required by a bound introduced by this call
60  | /                 Cors::default() // allowed_origin return access-control-allow-origin: * by default
61  | |                     .allowed_origin("http://127.0.0.1:3000")
62  | |                     .allowed_origin("http://localhost:3000")
63  | |                     .send_wildcard()
...   |
66  | |                     .allowed_header(http::header::CONTENT_TYPE)
67  | |                     .max_age(3600),
    | |__________________________________^ the trait `actix_web::dev::Transform<actix_web::app_service::AppRouting, ServiceRequest>` is not implemented for `Cors`
    |
    = help: the following other types implement trait `actix_web::dev::Transform<S, Req>`:
              <Arc<T> as actix_web::dev::Transform<S, Req>>
              <Compress as actix_web::dev::Transform<S, ServiceRequest>>
              <Condition<T> as actix_web::dev::Transform<S, Req>>
              <DefaultHeaders as actix_web::dev::Transform<S, ServiceRequest>>
              <ErrorHandlers<B> as actix_web::dev::Transform<S, ServiceRequest>>
              <NormalizePath as actix_web::dev::Transform<S, ServiceRequest>>
              <Rc<T> as actix_web::dev::Transform<S, Req>>
              <actix_service::transform_err::TransformMapInitErr<T, S, Req, F, E> as actix_web::dev::Transform<S, Req>>
            and 2 others
note: required by a bound in `App::<T>::wrap`
   --> /Users/nshv/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-4.2.1/src/app.rs:364:12
    |
364 |           M: Transform<
    |  ____________^
365 | |                 T::Service,
366 | |                 ServiceRequest,
367 | |                 Response = ServiceResponse<B>,
368 | |                 Error = Error,
369 | |                 InitError = (),
370 | |             > + 'static,
    | |_____________^ required by this bound in `App::<T>::wrap`

warning: use of deprecated associated function `actix_web::App::<T>::data`: Use `.app_data(Data::new(val))` instead.
  --> src/main.rs:69:14
   |
69 |             .data(pool.clone())
   |              ^^^^
   |
   = note: `#[warn(deprecated)]` on by default

error[E0277]: the trait bound `Authentication: actix_web::dev::Transform<<impl actix_web::dev::ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse<actix
_web::middleware::logger::StreamLog<_>>, Error = actix_web::Error, InitError = ()> as actix_web::dev::ServiceFactory<ServiceRequest>>::Service, ServiceRequest>` is not sat
isfied
   --> src/main.rs:71:19
    |
71  |             .wrap(crate::middleware::auth_middleware::Authentication) // Comment this line of code if you want to integrate with yew-addr...
    |              ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `actix_web::dev::Transform<<impl actix_web::dev::ServiceFactory<ServiceRequest, Config
 = (), Response = ServiceResponse<actix_web::middleware::logger::StreamLog<_>>, Error = actix_web::Error, InitError = ()> as actix_web::dev::ServiceFactory<ServiceRequest>
>::Service, ServiceRequest>` is not implemented for `Authentication`
    |              |
    |              required by a bound introduced by this call
    |
    = help: the following other types implement trait `actix_web::dev::Transform<S, Req>`:
              <Arc<T> as actix_web::dev::Transform<S, Req>>
              <Compress as actix_web::dev::Transform<S, ServiceRequest>>
              <Condition<T> as actix_web::dev::Transform<S, Req>>
              <DefaultHeaders as actix_web::dev::Transform<S, ServiceRequest>>
              <ErrorHandlers<B> as actix_web::dev::Transform<S, ServiceRequest>>
              <NormalizePath as actix_web::dev::Transform<S, ServiceRequest>>
              <Rc<T> as actix_web::dev::Transform<S, Req>>
              <actix_service::transform_err::TransformMapInitErr<T, S, Req, F, E> as actix_web::dev::Transform<S, Req>>
            and 2 others
note: required by a bound in `App::<T>::wrap`
   --> /Users/nshv/.cargo/registry/src/github.com-1ecc6299db9ec823/actix-web-4.2.1/src/app.rs:364:12
    |
364 |           M: Transform<
    |  ____________^
365 | |                 T::Service,
366 | |                 ServiceRequest,
367 | |                 Response = ServiceResponse<B>,
368 | |                 Error = Error,
369 | |                 InitError = (),
370 | |             > + 'static,
    | |_____________^ required by this bound in `App::<T>::wrap`

error[E0599]: the method `call` exists for reference `&<impl actix_web::dev::ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse<_>, Error = actix_web::
Error, InitError = ()> as actix_web::dev::ServiceFactory<ServiceRequest>>::Service`, but its trait bounds were not satisfied
  --> src/main.rs:72:37
   |
72 |             .wrap_fn(|req, srv| srv.call(req).map(|res| res))
   |                                     ^^^^ method cannot be called on `&<impl actix_web::dev::ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse<_>,
 Error = actix_web::Error, InitError = ()> as actix_web::dev::ServiceFactory<ServiceRequest>>::Service` due to unsatisfied trait bounds
   |
   = note: the following trait bounds were not satisfied:
           `<impl actix_web::dev::ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse<_>, Error = actix_web::Error, InitError = ()> as actix_web::dev::S
erviceFactory<ServiceRequest>>::Service: Fn<_>`
           which is required by `&<impl actix_web::dev::ServiceFactory<ServiceRequest, Config = (), Response = ServiceResponse<_>, Error = actix_web::Error, InitError = ()
> as actix_web::dev::ServiceFactory<ServiceRequest>>::Service: Fn<_>`
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
3  | use crate::actix_web::dev::Service;
   |

warning: unused import: `futures::FutureExt`
  --> src/main.rs:40:5
   |
40 | use futures::FutureExt;
   |     ^^^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused import: `actix_service::Service`
  --> src/main.rs:38:5
   |
38 | use actix_service::Service;
   |     ^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0277, E0432, E0599.
For more information about an error, try `rustc --explain E0277`.
warning: `actix-web-rest-api-with-jwt` (bin "actix-web-rest-api-with-jwt") generated 3 warnings
error: could not compile `actix-web-rest-api-with-jwt` due to 6 previous errors; 3 warnings emitted