C++ Rest SDK
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
http_server_api.h
1 /***
2 * ==++==
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 * ==--==
17 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
18 *
19 * HTTP Library: exposes the entry points to the http server transport apis.
20 *
21 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
22 ****/
23 
24 #pragma once
25 
26 #if _WIN32_WINNT < _WIN32_WINNT_VISTA
27 #error "Error: http server APIs are not supported in XP"
28 #endif //_WIN32_WINNT < _WIN32_WINNT_VISTA
29 
30 #include <memory>
31 
32 #include "cpprest/http_listener.h"
33 
34 namespace web { namespace http
35 {
36 namespace experimental {
37 namespace details
38 {
39 
40 class http_server;
41 
50 {
51 public:
52 
56  static bool __cdecl has_listener();
57 
61  static void __cdecl register_server_api(std::unique_ptr<http_server> server_api);
62 
66  static void __cdecl unregister_server_api();
67 
72 
77 
81  static http_server * __cdecl server_api();
82 
83 private:
84 
86  static pplx::extensibility::critical_section_t s_lock;
87 
89  static void unsafe_register_server_api(std::unique_ptr<http_server> server_api);
90 
91  // Static instance of the HTTP server API.
92  static std::unique_ptr<http_server> s_server_api;
93 
95  static pplx::details::atomic_long s_registrations;
96 
97  // Static only class. No creation.
99 };
100 
101 }}}} // namespaces
static pplx::task< void > __cdecl unregister_listener(_In_ web::http::experimental::listener::details::http_listener_impl *pListener)
Unregisters the given listener and stops listening for HTTP requests.
The web namespace contains functionality common to multiple protocols like HTTP and WebSockets...
Definition: base_uri.h:37
static http_server *__cdecl server_api()
Gets static HTTP server API. Could be null if no registered listeners.
static void __cdecl unregister_server_api()
Clears the http server API.
static pplx::task< void > __cdecl register_listener(_In_ web::http::experimental::listener::details::http_listener_impl *pListener)
Registers a listener for HTTP requests and starts receiving.
static bool __cdecl has_listener()
Returns whether or not any listeners are registered.
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: pplxtasks.h:4173
static void __cdecl register_server_api(std::unique_ptr< http_server > server_api)
Registers a HTTP server API.
Singleton class used to register for http requests and send responses.
Definition: http_server_api.h:49
Internal class for pointer to implementation design pattern.
Definition: http_listener.h:171
Interface http listeners interact with for receiving and responding to http requests.
Definition: http_server.h:42