File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree File renamed without changes.
Original file line number Diff line number Diff line change 11use axum:: response:: IntoResponse ;
2- use hyper:: { header :: ToStrError , StatusCode } ;
2+ use hyper:: StatusCode ;
33use tonic:: metadata:: errors:: InvalidMetadataValueBytes ;
44
55use crate :: {
@@ -69,7 +69,7 @@ pub enum Error {
6969 #[ error( "Invalid namespace" ) ]
7070 InvalidNamespace ,
7171 #[ error( "Invalid namespace bytes: `{0}`" ) ]
72- InvalidNamespaceBytes ( # [ from ] ToStrError ) ,
72+ InvalidNamespaceBytes ( Box < dyn std :: error :: Error + Sync + Send + ' static > ) ,
7373 #[ error( "Replica meta error: {0}" ) ]
7474 ReplicaMetaError ( #[ from] libsql_replication:: meta:: Error ) ,
7575 #[ error( "Replicator error: {0}" ) ]
Original file line number Diff line number Diff line change 11use std:: sync:: Arc ;
22
33use axum:: extract:: { FromRequestParts , Path } ;
4+ use base64:: prelude:: * ;
45use hyper:: http:: request:: Parts ;
56use hyper:: HeaderMap ;
67use libsql_replication:: rpc:: replication:: NAMESPACE_METADATA_KEY ;
@@ -73,8 +74,13 @@ fn try_namespace_from_host(
7374fn try_namespace_from_metadata ( metadata : & axum:: http:: HeaderValue ) -> Result < NamespaceName , Error > {
7475 metadata
7576 . to_str ( )
76- . map_err ( |s| Error :: InvalidNamespaceBytes ( s) )
77- . and_then ( |ns| NamespaceName :: from_string ( ns. into ( ) ) )
77+ . map_err ( |s| Error :: InvalidNamespaceBytes ( Box :: new ( s) ) )
78+ . and_then ( |encoded| {
79+ BASE64_STANDARD_NO_PAD
80+ . decode ( encoded)
81+ . map_err ( |e| Error :: InvalidNamespaceBytes ( Box :: new ( e) ) )
82+ } )
83+ . and_then ( |ns| NamespaceName :: from_bytes ( ns. into ( ) ) )
7884}
7985
8086pub struct MakeConnectionExtractorPath ( pub Arc < dyn MakeConnection < Connection = Connection > > ) ;
You can’t perform that action at this time.
0 commit comments