42class Client :
public std::enable_shared_from_this<Client> {
44 using SigningKeyType = ::ipfs::crypto::SigningKeyType;
45 using MimeTypeDeduction = std::function<
46 std::string(std::string, std::string_view, std::string
const&)>;
47 using UrlUnescaping = std::function<std::string(std::string_view)>;
50 using DnslinkFallbackSwitch = std::function<bool()>;
55 std::shared_ptr<Partition> partition(std::string key);
61 std::shared_ptr<gw::Requestor> requestor();
63 Client& with(std::unique_ptr<ctx::HttpApi>);
64 Client& with(std::unique_ptr<ctx::DnsTxtLookup>);
65 Client& with(std::unique_ptr<ctx::GatewayConfig>);
66 Client& with(std::unique_ptr<ctx::JsonParser>);
67 Client& with(std::unique_ptr<ctx::CborParser>);
68 Client& with(std::shared_ptr<gw::Requestor>);
69 Client& with(SigningKeyType, std::unique_ptr<crypto::SignatureVerifier>);
70 Client& with(MimeTypeDeduction);
71 Client& with(UrlUnescaping);
72 Client& with(DnslinkFallbackSwitch);
81 std::string_view content,
82 std::string
const& url);
92 using ByteView = ::ipfs::ByteView;
93 bool VerifyKeySignature(SigningKeyType,
96 ByteView key_bytes)
const;
98 std::optional<std::vector<Byte>> Hash(HashType, ByteView data);
100 bool DnslinkFallback()
const;
103 std::unordered_map<HashType, std::unique_ptr<crypto::Hasher>> hashers_;
104 std::unordered_map<SigningKeyType, std::unique_ptr<crypto::SignatureVerifier>>
106 std::unique_ptr<ctx::HttpApi> http_api_;
107 std::unique_ptr<ctx::DnsTxtLookup> dns_txt_;
108 std::unique_ptr<ctx::GatewayConfig> gateway_config_;
109 std::unique_ptr<ctx::JsonParser> json_parser_;
110 std::unique_ptr<ctx::CborParser> cbor_parser_;
111 MimeTypeDeduction deduce_mime_type_;
112 UrlUnescaping unescape_;
113 std::shared_ptr<gw::Requestor> rtor_;
114 std::unordered_map<std::string, std::shared_ptr<Partition>> partitions_;
115 DnslinkFallbackSwitch dns_fb_;
std::string MimeType(std::string extension, std::string_view content, std::string const &url)
Determine a mime type for a given file.