| 1 | struct Response {} |
| 2 | |
| 3 | pub struct Route { |
| 4 | handler fn (mut App) Response |
| 5 | middlewares []fn (mut app App) ?Response |
| 6 | } |
| 7 | |
| 8 | struct App { |
| 9 | routes []Route |
| 10 | } |
| 11 | |
| 12 | pub fn check_auth(mut app App) ?Response { |
| 13 | return none |
| 14 | } |
| 15 | |
| 16 | fn test_anon_fn_with_option() { |
| 17 | app := App{ |
| 18 | routes: [ |
| 19 | Route{ |
| 20 | middlewares: [ |
| 21 | check_auth, |
| 22 | ] |
| 23 | }, |
| 24 | ] |
| 25 | } |
| 26 | println(app) |
| 27 | app_str := '${app}' |
| 28 | assert app_str.contains('handler: fn (mut App) Response') |
| 29 | assert app_str.contains('middlewares: [fn (mut App) ?Response]') |
| 30 | } |
| 31 | |