@@ -7,7 +7,7 @@ use actix_cors::Cors;
77use actix_web:: dev:: Server ;
88use actix_web:: { App , HttpRequest , HttpServer , Responder , web} ;
99use htsget_config:: config:: advanced:: cors:: CorsConfig ;
10- use htsget_config:: config:: service_info:: ServiceInfo ;
10+ use htsget_config:: config:: service_info:: { PackageInfo , ServiceInfo } ;
1111use htsget_config:: config:: ticket_server:: TicketServerConfig ;
1212pub use htsget_config:: config:: { Config , USAGE } ;
1313use htsget_http:: error:: HtsGetError ;
@@ -25,6 +25,7 @@ pub struct AppState<H: HtsGet> {
2525 pub htsget : H ,
2626 pub config_service_info : ServiceInfo ,
2727 pub auth : Option < Auth > ,
28+ pub package_info : Option < PackageInfo > ,
2829}
2930
3031/// Configure the query server.
@@ -33,12 +34,14 @@ pub fn configure_server<H: HtsGet + Clone + Send + Sync + 'static>(
3334 htsget : H ,
3435 config_service_info : ServiceInfo ,
3536 auth : Option < Auth > ,
37+ package_info : Option < PackageInfo > ,
3638) {
3739 service_config
3840 . app_data ( web:: Data :: new ( AppState {
3941 htsget,
4042 config_service_info,
4143 auth,
44+ package_info,
4245 } ) )
4346 . service (
4447 web:: scope ( "/reads" )
@@ -135,16 +138,26 @@ pub fn run_server<H: HtsGet + Clone + Send + Sync + 'static>(
135138 htsget : H ,
136139 config : TicketServerConfig ,
137140 service_info : ServiceInfo ,
141+ package_info : PackageInfo ,
138142) -> io:: Result < Server > {
139- let app =
140- |htsget : H , config : TicketServerConfig , service_info : ServiceInfo , auth : Option < Auth > | {
141- App :: new ( )
142- . configure ( |service_config : & mut web:: ServiceConfig | {
143- configure_server ( service_config, htsget, service_info, auth) ;
144- } )
145- . wrap ( configure_cors ( config. cors ( ) . clone ( ) ) )
146- . wrap ( TracingLogger :: default ( ) )
147- } ;
143+ let app = |htsget : H ,
144+ config : TicketServerConfig ,
145+ service_info : ServiceInfo ,
146+ auth : Option < Auth > ,
147+ package_info : PackageInfo | {
148+ App :: new ( )
149+ . configure ( |service_config : & mut web:: ServiceConfig | {
150+ configure_server (
151+ service_config,
152+ htsget,
153+ service_info,
154+ auth,
155+ Some ( package_info) ,
156+ ) ;
157+ } )
158+ . wrap ( configure_cors ( config. cors ( ) . clone ( ) ) )
159+ . wrap ( TracingLogger :: default ( ) )
160+ } ;
148161
149162 let auth = config
150163 . auth ( )
@@ -160,6 +173,7 @@ pub fn run_server<H: HtsGet + Clone + Send + Sync + 'static>(
160173 config_copy. clone ( ) ,
161174 service_info. clone ( ) ,
162175 auth. clone ( ) ,
176+ package_info. clone ( ) ,
163177 )
164178 } ) ;
165179
@@ -195,6 +209,7 @@ mod tests {
195209
196210 use crate :: Config ;
197211 use htsget_axum:: server:: BindServer ;
212+ use htsget_config:: package_info;
198213 use htsget_config:: storage:: file:: default_path;
199214 use htsget_config:: types:: JsonResponse ;
200215 use htsget_http:: middleware:: auth:: AuthBuilder ;
@@ -346,6 +361,7 @@ mod tests {
346361 self . config . clone ( ) . into_locations ( ) ,
347362 self . config . service_info ( ) . clone ( ) ,
348363 self . auth . clone ( ) ,
364+ Some ( package_info ! ( ) ) ,
349365 ) ;
350366 } )
351367 . wrap ( configure_cors ( self . config . ticket_server ( ) . cors ( ) . clone ( ) ) ) ;
0 commit comments