File tree 1 file changed +2
-10
lines changed
1 file changed +2
-10
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,6 @@ struct OutputPayload {
25
25
numbers : Vec < u8 > ,
26
26
}
27
27
28
- fn get_name_or_default ( name : & str ) -> & str {
29
- if name. trim ( ) . is_empty ( ) {
30
- "Anonymous"
31
- } else {
32
- name
33
- }
34
- }
35
-
36
28
/// This is where most of the work of our Rust lambda is done. Once an incoming request arrives
37
29
/// at our lambda, this function will be invoked along with the request payload we have defined
38
30
/// earlier. It expects a LambdaResponse containing our response payload. In this example,
@@ -42,13 +34,13 @@ fn lambda_handler(
42
34
_c : Context ,
43
35
) -> Result < LambdaResponse , HandlerError > {
44
36
let payload = e. body ( ) ;
45
- let name = get_name_or_default ( & payload. name ) ;
37
+ let name = & payload. name . to_uppercase ( ) ;
46
38
let count = std:: cmp:: min ( std:: cmp:: max ( 2 , payload. count ) , 20 ) ;
47
39
48
40
let response = LambdaResponseBuilder :: new ( )
49
41
. with_status ( 200 )
50
42
. with_json ( OutputPayload {
51
- message : format ! ( "Hi, {} . Your lucky numbers are:" , name) ,
43
+ message : format ! ( "Hi, '{}' . Your lucky numbers are:" , name) ,
52
44
numbers : ( 1 ..=count) . map ( |_| thread_rng ( ) . gen_range ( 1 , 42 ) ) . collect ( ) ,
53
45
} )
54
46
. build ( ) ;
You can’t perform that action at this time.
0 commit comments