mirror of
https://github.com/actix/examples
synced 2024-11-27 16:02:57 +01:00
Minor lints and clippies (#557)
This commit is contained in:
parent
7a957cee6e
commit
912de4aa46
@ -5,6 +5,7 @@ use serde::Deserialize;
|
|||||||
use crate::errors::ServiceError;
|
use crate::errors::ServiceError;
|
||||||
use crate::models::{Invitation, Pool, SlimUser, User};
|
use crate::models::{Invitation, Pool, SlimUser, User};
|
||||||
use crate::utils::hash_password;
|
use crate::utils::hash_password;
|
||||||
|
|
||||||
// UserData is used to extract data from a post request by the client
|
// UserData is used to extract data from a post request by the client
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
pub struct UserData {
|
pub struct UserData {
|
||||||
|
@ -103,7 +103,7 @@ mod tests {
|
|||||||
.build(manager)
|
.build(manager)
|
||||||
.expect("Failed to create pool.");
|
.expect("Failed to create pool.");
|
||||||
|
|
||||||
let mut app = test::init_service(
|
let app = test::init_service(
|
||||||
App::new()
|
App::new()
|
||||||
.app_data(web::Data::new(pool.clone()))
|
.app_data(web::Data::new(pool.clone()))
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
@ -120,7 +120,7 @@ mod tests {
|
|||||||
})
|
})
|
||||||
.to_request();
|
.to_request();
|
||||||
|
|
||||||
let resp: models::User = test::call_and_read_body_json(&mut app, req).await;
|
let resp: models::User = test::call_and_read_body_json(&app, req).await;
|
||||||
|
|
||||||
assert_eq!(resp.name, "Test user");
|
assert_eq!(resp.name, "Test user");
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ mod tests {
|
|||||||
.uri(&format!("/user/{}", resp.id))
|
.uri(&format!("/user/{}", resp.id))
|
||||||
.to_request();
|
.to_request();
|
||||||
|
|
||||||
let resp: models::User = test::call_and_read_body_json(&mut app, req).await;
|
let resp: models::User = test::call_and_read_body_json(&app, req).await;
|
||||||
|
|
||||||
assert_eq!(resp.name, "Test user");
|
assert_eq!(resp.name, "Test user");
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ async fn index() -> HttpResponse {
|
|||||||
<form target="/" method="post" enctype="multipart/form-data" id="myForm" >
|
<form target="/" method="post" enctype="multipart/form-data" id="myForm" >
|
||||||
<input type="text" id="text" name="text" value="test_text"/>
|
<input type="text" id="text" name="text" value="test_text"/>
|
||||||
<input type="number" id="number" name="number" value="123123"/>
|
<input type="number" id="number" name="number" value="123123"/>
|
||||||
|
|
||||||
<input type="button" value="Submit" onclick="myFunction()"></button>
|
<input type="button" value="Submit" onclick="myFunction()"></button>
|
||||||
</form>
|
</form>
|
||||||
<input type="file" multiple name="file" id="myFile"/>
|
<input type="file" multiple name="file" id="myFile"/>
|
||||||
@ -55,7 +54,6 @@ async fn index() -> HttpResponse {
|
|||||||
console.log(obj);
|
console.log(obj);
|
||||||
console.log(json);
|
console.log(json);
|
||||||
|
|
||||||
|
|
||||||
formData.append("data", json);
|
formData.append("data", json);
|
||||||
formData.append("myFile", myFile.files[0]);
|
formData.append("myFile", myFile.files[0]);
|
||||||
|
|
||||||
@ -64,7 +62,6 @@ async fn index() -> HttpResponse {
|
|||||||
request.send(formData);
|
request.send(formData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</html>"#;
|
</html>"#;
|
||||||
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate juniper;
|
|
||||||
|
|
||||||
use actix_cors::Cors;
|
use actix_cors::Cors;
|
||||||
use actix_web::{middleware::Logger, web::Data, App, HttpServer};
|
use actix_web::{middleware::Logger, web::Data, App, HttpServer};
|
||||||
|
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use juniper::GraphQLInputObject;
|
||||||
use mysql::{from_row, params, Error as DBError, Row};
|
use mysql::{from_row, params, Error as DBError, Row};
|
||||||
|
|
||||||
use crate::schemas::root::Context;
|
use crate::schemas::root::Context;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
use juniper::{EmptySubscription, FieldError, FieldResult, RootNode};
|
use juniper::{
|
||||||
|
graphql_object, graphql_value, EmptySubscription, FieldError, FieldResult, RootNode,
|
||||||
|
};
|
||||||
use mysql::{from_row, params, Error as DBError, Row};
|
use mysql::{from_row, params, Error as DBError, Row};
|
||||||
|
|
||||||
use crate::db::Pool;
|
use crate::db::Pool;
|
||||||
@ -14,7 +16,7 @@ impl juniper::Context for Context {}
|
|||||||
|
|
||||||
pub struct QueryRoot;
|
pub struct QueryRoot;
|
||||||
|
|
||||||
#[juniper::graphql_object(Context = Context)]
|
#[graphql_object(Context = Context)]
|
||||||
impl QueryRoot {
|
impl QueryRoot {
|
||||||
#[graphql(description = "List of all users")]
|
#[graphql(description = "List of all users")]
|
||||||
fn users(context: &Context) -> FieldResult<Vec<User>> {
|
fn users(context: &Context) -> FieldResult<Vec<User>> {
|
||||||
@ -99,7 +101,7 @@ impl QueryRoot {
|
|||||||
|
|
||||||
pub struct MutationRoot;
|
pub struct MutationRoot;
|
||||||
|
|
||||||
#[juniper::graphql_object(Context = Context)]
|
#[graphql_object(Context = Context)]
|
||||||
impl MutationRoot {
|
impl MutationRoot {
|
||||||
fn create_user(context: &Context, user: UserInput) -> FieldResult<User> {
|
fn create_user(context: &Context, user: UserInput) -> FieldResult<User> {
|
||||||
let mut conn = context.dbpool.get().unwrap();
|
let mut conn = context.dbpool.get().unwrap();
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
use juniper::{graphql_object, GraphQLInputObject};
|
||||||
use mysql::{from_row, params};
|
use mysql::{from_row, params};
|
||||||
|
|
||||||
use crate::schemas::product::Product;
|
use crate::schemas::product::Product;
|
||||||
@ -18,7 +19,7 @@ pub struct UserInput {
|
|||||||
pub email: String,
|
pub email: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[juniper::graphql_object(Context = Context)]
|
#[graphql_object(Context = Context)]
|
||||||
impl User {
|
impl User {
|
||||||
fn id(&self) -> &str {
|
fn id(&self) -> &str {
|
||||||
&self.id
|
&self.id
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#[macro_use]
|
|
||||||
extern crate prost_derive;
|
|
||||||
|
|
||||||
use actix_protobuf::{ProtoBuf, ProtoBufResponseBuilder as _};
|
use actix_protobuf::{ProtoBuf, ProtoBufResponseBuilder as _};
|
||||||
use actix_web::{middleware, web, App, HttpResponse, HttpServer, Result};
|
use actix_web::{middleware, web, App, HttpResponse, HttpServer, Result};
|
||||||
|
use prost_derive::Message;
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Message)]
|
#[derive(Clone, PartialEq, Message)]
|
||||||
pub struct MyObj {
|
pub struct MyObj {
|
||||||
|
Loading…
Reference in New Issue
Block a user