@@ -29,7 +29,7 @@ fn certificate_certificates(
29
29
) -> impl Filter < Extract = ( impl warp:: Reply , ) , Error = warp:: Rejection > + Clone {
30
30
warp:: path!( "certificates" )
31
31
. and ( warp:: get ( ) )
32
- . and ( middlewares:: with_certifier_service ( dependency_manager) )
32
+ . and ( middlewares:: with_http_message_service ( dependency_manager) )
33
33
. and_then ( handlers:: certificate_certificates)
34
34
}
35
35
@@ -39,16 +39,14 @@ fn certificate_certificate_hash(
39
39
) -> impl Filter < Extract = ( impl warp:: Reply , ) , Error = warp:: Rejection > + Clone {
40
40
warp:: path!( "certificate" / String )
41
41
. and ( warp:: get ( ) )
42
- . and ( middlewares:: with_certifier_service ( dependency_manager) )
42
+ . and ( middlewares:: with_http_message_service ( dependency_manager) )
43
43
. and_then ( handlers:: certificate_certificate_hash)
44
44
}
45
45
46
46
mod handlers {
47
47
use crate :: {
48
- http_server:: routes:: reply,
49
- message_adapters:: { ToCertificateListMessageAdapter , ToCertificateMessageAdapter } ,
50
- services:: CertifierService ,
51
- CertificatePendingStore , ToCertificatePendingMessageAdapter ,
48
+ http_server:: routes:: reply, services:: HttpMessageService , CertificatePendingStore ,
49
+ ToCertificatePendingMessageAdapter ,
52
50
} ;
53
51
54
52
use mithril_common:: messages:: ToMessageAdapter ;
@@ -80,18 +78,15 @@ mod handlers {
80
78
81
79
/// List all Certificates
82
80
pub async fn certificate_certificates (
83
- certifier_service : Arc < dyn CertifierService > ,
81
+ http_message_service : Arc < dyn HttpMessageService > ,
84
82
) -> Result < impl warp:: Reply , Infallible > {
85
83
debug ! ( "⇄ HTTP SERVER: certificate_certificates" , ) ;
86
84
87
- match certifier_service
88
- . get_latest_certificates ( LIST_MAX_ITEMS )
85
+ match http_message_service
86
+ . get_last_certificates ( LIST_MAX_ITEMS )
89
87
. await
90
88
{
91
- Ok ( certificates) => Ok ( reply:: json (
92
- & ToCertificateListMessageAdapter :: adapt ( certificates) ,
93
- StatusCode :: OK ,
94
- ) ) ,
89
+ Ok ( certificates) => Ok ( reply:: json ( & certificates, StatusCode :: OK ) ) ,
95
90
Err ( err) => {
96
91
warn ! ( "certificate_certificates::error" ; "error" => ?err) ;
97
92
Ok ( reply:: internal_server_error ( err) )
@@ -102,21 +97,18 @@ mod handlers {
102
97
/// Certificate by certificate hash
103
98
pub async fn certificate_certificate_hash (
104
99
certificate_hash : String ,
105
- certifier_service : Arc < dyn CertifierService > ,
100
+ http_message_service : Arc < dyn HttpMessageService > ,
106
101
) -> Result < impl warp:: Reply , Infallible > {
107
102
debug ! (
108
103
"⇄ HTTP SERVER: certificate_certificate_hash/{}" ,
109
104
certificate_hash
110
105
) ;
111
106
112
- match certifier_service
113
- . get_certificate_by_hash ( & certificate_hash)
107
+ match http_message_service
108
+ . get_certificate ( & certificate_hash)
114
109
. await
115
110
{
116
- Ok ( Some ( certificate) ) => Ok ( reply:: json (
117
- & ToCertificateMessageAdapter :: adapt ( certificate) ,
118
- StatusCode :: OK ,
119
- ) ) ,
111
+ Ok ( Some ( certificate) ) => Ok ( reply:: json ( & certificate, StatusCode :: OK ) ) ,
120
112
Ok ( None ) => Ok ( reply:: empty ( StatusCode :: NOT_FOUND ) ) ,
121
113
Err ( err) => {
122
114
warn ! ( "certificate_certificate_hash::error" ; "error" => ?err) ;
0 commit comments