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