@@ -5,46 +5,50 @@ use axum_macros::debug_handler;
55
66use crate :: error:: api:: ApiError ;
77use crate :: response:: block:: BlockResponse ;
8+ use crate :: response:: headers;
89use crate :: state:: common:: CommonState ;
910
1011#[ debug_handler]
1112pub async fn get_block_by_height (
1213 _headers : HeaderMap ,
1314 Path ( value) : Path < i32 > ,
1415 State ( state) : State < CommonState > ,
15- ) -> Result < Json < BlockResponse > , ApiError > {
16+ ) -> Result < ( HeaderMap , Json < BlockResponse > ) , ApiError > {
1617 let ( block, prev_block, transactions) =
1718 state. block_service . get_block_by_height ( value) . await ?;
1819
1920 let response = BlockResponse :: from ( block, prev_block, transactions) ;
21+ let headers = headers:: with_cache ( ) ;
2022
21- Ok ( Json ( response) )
23+ Ok ( ( headers , Json ( response) ) )
2224}
2325
2426#[ debug_handler]
2527pub async fn get_block_by_timestamp (
2628 _headers : HeaderMap ,
2729 Path ( value) : Path < i64 > ,
2830 State ( state) : State < CommonState > ,
29- ) -> Result < Json < BlockResponse > , ApiError > {
31+ ) -> Result < ( HeaderMap , Json < BlockResponse > ) , ApiError > {
3032 let ( block, prev_block, transactions) =
3133 state. block_service . get_block_by_timestamp ( value) . await ?;
3234
3335 let response = BlockResponse :: from ( block, prev_block, transactions) ;
36+ let headers = headers:: with_cache ( ) ;
3437
35- Ok ( Json ( response) )
38+ Ok ( ( headers , Json ( response) ) )
3639}
3740
3841#[ debug_handler]
3942pub async fn get_block_by_hash (
4043 _headers : HeaderMap ,
4144 Path ( value) : Path < String > ,
4245 State ( state) : State < CommonState > ,
43- ) -> Result < Json < BlockResponse > , ApiError > {
46+ ) -> Result < ( HeaderMap , Json < BlockResponse > ) , ApiError > {
4447 let ( block, prev_block, transactions) =
4548 state. block_service . get_block_by_hash ( value) . await ?;
4649
4750 let response = BlockResponse :: from ( block, prev_block, transactions) ;
51+ let headers = headers:: with_cache ( ) ;
4852
49- Ok ( Json ( response) )
53+ Ok ( ( headers , Json ( response) ) )
5054}
0 commit comments