@@ -9,14 +9,14 @@ use futures::future;
9
9
use opendal:: Operator ;
10
10
use sqlx:: PgPool ;
11
11
12
- use rsync_core:: s3:: { build_operator , S3Opts } ;
12
+ use rsync_core:: s3:: { S3Opts , build_operator } ;
13
13
use rsync_core:: utils:: AbortJoinHandle ;
14
14
15
15
use crate :: cache:: NSCache ;
16
16
use crate :: handler;
17
17
use crate :: listener:: RevisionsChangeListener ;
18
18
use crate :: opts:: { Config , Endpoint } ;
19
- use crate :: state:: { listen_for_updates , State } ;
19
+ use crate :: state:: { State , listen_for_updates } ;
20
20
21
21
pub struct Prefix ( pub String ) ;
22
22
@@ -45,7 +45,10 @@ pub async fn configure<B: for<'a> Fn(&'a Config, &'a Endpoint) -> Result<Operato
45
45
opts : & Config ,
46
46
op_builder : B ,
47
47
pool : PgPool ,
48
- ) -> Result < ( AbortJoinHandle < ( ) > , impl Fn ( & mut ServiceConfig ) + Clone + use < B > ) > {
48
+ ) -> Result < (
49
+ AbortJoinHandle < ( ) > ,
50
+ impl Fn ( & mut ServiceConfig ) + Clone + use < B > ,
51
+ ) > {
49
52
let listener = RevisionsChangeListener :: default ( ) ;
50
53
let listener_handle = listener. spawn ( & pool) ;
51
54
@@ -74,29 +77,26 @@ pub async fn configure<B: for<'a> Fn(&'a Config, &'a Endpoint) -> Result<Operato
74
77
. await ?,
75
78
) ;
76
79
77
- Ok ( (
78
- listener_handle,
79
- move |cfg : & mut ServiceConfig | {
80
- for ( prefix, endpoint, revision, guard, cache, op) in & * prefix_state {
81
- let state = State :: new ( revision. clone ( ) , guard. clone ( ) ) ;
82
- cfg. service (
83
- web:: scope ( & format ! ( "/{prefix}" ) )
84
- . app_data ( Data :: new ( Prefix ( prefix. clone ( ) ) ) )
85
- . app_data ( Data :: new ( state) )
86
- . app_data ( Data :: from ( endpoint. clone ( ) ) )
87
- . app_data ( Data :: from ( cache. clone ( ) ) )
88
- . app_data ( Data :: new ( op. clone ( ) ) )
89
- . route (
90
- "/_revisions" ,
91
- web:: route ( ) . guard ( get_or_head ( ) ) . to ( handler:: rev_handler) ,
92
- )
93
- . service (
94
- web:: resource ( [ "" , "/{path:(.|/)*}" ] )
95
- . route ( web:: route ( ) . guard ( get_or_head ( ) ) . to ( handler:: main_handler) ) ,
96
- ) ,
97
- ) ;
98
- }
99
- cfg. app_data ( Data :: new ( pool. clone ( ) ) ) ;
100
- } ,
101
- ) )
102
- }
80
+ Ok ( ( listener_handle, move |cfg : & mut ServiceConfig | {
81
+ for ( prefix, endpoint, revision, guard, cache, op) in & * prefix_state {
82
+ let state = State :: new ( revision. clone ( ) , guard. clone ( ) ) ;
83
+ cfg. service (
84
+ web:: scope ( & format ! ( "/{prefix}" ) )
85
+ . app_data ( Data :: new ( Prefix ( prefix. clone ( ) ) ) )
86
+ . app_data ( Data :: new ( state) )
87
+ . app_data ( Data :: from ( endpoint. clone ( ) ) )
88
+ . app_data ( Data :: from ( cache. clone ( ) ) )
89
+ . app_data ( Data :: new ( op. clone ( ) ) )
90
+ . route (
91
+ "/_revisions" ,
92
+ web:: route ( ) . guard ( get_or_head ( ) ) . to ( handler:: rev_handler) ,
93
+ )
94
+ . service (
95
+ web:: resource ( [ "" , "/{path:(.|/)*}" ] )
96
+ . route ( web:: route ( ) . guard ( get_or_head ( ) ) . to ( handler:: main_handler) ) ,
97
+ ) ,
98
+ ) ;
99
+ }
100
+ cfg. app_data ( Data :: new ( pool. clone ( ) ) ) ;
101
+ } ) )
102
+ }
0 commit comments