File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
exercises/tiered_pricing/solutions/isaac1024_baby-steps/src Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 1- use actix_web:: { HttpResponse , Responder } ;
1+ use actix_web:: { web , HttpResponse , Responder } ;
22use serde:: { Deserialize , Serialize } ;
33use std:: fmt;
44
5+ #[ derive( Deserialize ) ]
6+ pub struct Pricing {
7+ subscriptions : u32 ,
8+ }
9+
510#[ derive( Serialize , Deserialize ) ]
611struct Subscriptions {
712 pricing : u32 ,
813}
914
10- pub async fn tiered_pricing ( ) -> impl Responder {
11- HttpResponse :: Ok ( ) . json ( Subscriptions { pricing : 0 } )
15+ pub async fn tiered_pricing ( pricing : web:: Query < Pricing > ) -> impl Responder {
16+ let total_price = get_total_subscription_price ( pricing. subscriptions ) . unwrap ( ) ;
17+ HttpResponse :: Ok ( ) . json ( Subscriptions {
18+ pricing : total_price,
19+ } )
1220}
1321
1422type SubscriptionResult < T > = Result < T , NumberSubscriptionsError > ;
You can’t perform that action at this time.
0 commit comments