Loading [MathJax]/extensions/tex2jax.js
azure-storage-common
All Classes Functions Variables Pages
storage_service_version_policy.hpp
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4#pragma once
5
6#include <azure/core/http/policies/policy.hpp>
7
8#include <memory>
9#include <string>
10
11namespace Azure { namespace Storage { namespace _internal {
12
13 class StorageServiceVersionPolicy final : public Azure::Core::Http::Policies::HttpPolicy {
14 public:
15 explicit StorageServiceVersionPolicy(std::string apiVersion)
16 : m_apiVersion(std::move(apiVersion))
17 {
18 }
19
20 std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy> Clone() const override
21 {
22 return std::make_unique<StorageServiceVersionPolicy>(*this);
23 }
24
25 std::unique_ptr<Azure::Core::Http::RawResponse> Send(
26 Azure::Core::Http::Request& request,
27 Azure::Core::Http::Policies::NextHttpPolicy nextPolicy,
28 const Azure::Core::Context& context) const override
29 {
30 if (!m_apiVersion.empty())
31 {
32 request.SetHeader(HttpHeaderXMsVersion, m_apiVersion);
33 }
34 return nextPolicy.Send(request, context);
35 }
36
37 private:
38 std::string m_apiVersion;
39 };
40
41}}} // namespace Azure::Storage::_internal