clean up
Some checks failed
continuous-integration/drone/push Build was killed

This commit is contained in:
Johannes Heuel
2022-10-02 13:28:48 +02:00
parent d5e318257d
commit c22050005c
8 changed files with 71 additions and 59 deletions

View File

@@ -145,7 +145,7 @@ fn main() {
let new_picture = NewPicture {
filepath: filepath.clone(),
created_at: created_at.clone(),
created_at,
focal_length: pe.focal_length.clone(),
shutter_speed: pe.shutter_speed.clone(),
width: pe.width,

View File

@@ -19,7 +19,7 @@ pub fn establish_connection() -> PgConnection {
.unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
}
pub fn create_picture<'a>(conn: &PgConnection, new_picture: NewPicture) -> usize {
pub fn create_picture(conn: &PgConnection, new_picture: NewPicture) -> usize {
use schema::pictures;
diesel::insert_into(pictures::table)

View File

@@ -31,8 +31,6 @@ use common::OutputPicture;
type DbPool = r2d2::Pool<ConnectionManager<PgConnection>>;
// type DbError = Box<dyn std::error::Error + Send + Sync>;
#[get("/api/pictures/")]
async fn get_pictures(pool: web::Data<DbPool>) -> Result<impl Responder> {
let conn = pool.get().unwrap();
@@ -91,10 +89,8 @@ async fn main() -> std::io::Result<()> {
let port = 8081;
log::info!("starting HTTP server at http://{}:{}", host, port);
// Start HTTP server
HttpServer::new(move || {
App::new()
// set up DB pool to be used with web::Data<Pool> extractor
.app_data(web::Data::new(pool.clone()))
.wrap(middleware::Logger::default())
.service(get_pictures)
@@ -106,9 +102,6 @@ async fn main() -> std::io::Result<()> {
.static_resources_location("./dist")
.finish(),
)
// .service(fs::Files::new("/", STATIC_FILES_PATH).index_file("index.html"))
// .service(get_user)
// .service(add_user)
})
.bind((host, port))?
.run()