1- use crate :: db:: write;
1+ use crate :: db:: { write, Database } ;
22use crate :: handlers:: html:: make_error;
33use crate :: id:: Id ;
4- use crate :: { AppState , Error } ;
4+ use crate :: { Error , Page } ;
55use axum:: extract:: { Form , State } ;
66use axum:: http:: HeaderMap ;
77use axum:: response:: { IntoResponse , Redirect } ;
@@ -43,7 +43,8 @@ impl From<Entry> for write::Entry {
4343}
4444
4545pub async fn post (
46- state : State < AppState > ,
46+ State ( page) : State < Page > ,
47+ State ( db) : State < Database > ,
4748 jar : SignedCookieJar ,
4849 headers : HeaderMap ,
4950 Form ( entry) : Form < Entry > ,
@@ -77,7 +78,7 @@ pub async fn post(
7778 . parse :: < i64 > ( )
7879 . map_err ( |err| Error :: CookieParsing ( err. to_string ( ) ) ) ?
7980 } else {
80- state . db . next_uid ( ) . await ?
81+ db. next_uid ( ) . await ?
8182 } ;
8283
8384 let mut entry: write:: Entry = entry. into ( ) ;
@@ -89,7 +90,7 @@ pub async fn post(
8990 url = format ! ( "burn/{url}" ) ;
9091 }
9192
92- state . db . insert ( id, entry) . await ?;
93+ db. insert ( id, entry) . await ?;
9394 let url = format ! ( "/{url}" ) ;
9495
9596 let cookie = Cookie :: build ( ( "uid" , uid. to_string ( ) ) )
@@ -101,7 +102,7 @@ pub async fn post(
101102 Ok ( ( jar. add ( cookie) , Redirect :: to ( & url) ) )
102103 }
103104 . await
104- . map_err ( |err| make_error ( err, state . page . clone ( ) ) )
105+ . map_err ( |err| make_error ( err, page) )
105106}
106107
107108#[ cfg( test) ]
0 commit comments