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.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 *
20 * HTTP Library: interface to implement HTTP server to service http_listeners.
21 *
22 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
23 ****/
24 
25 #pragma once
26 
27 #if _WIN32_WINNT < _WIN32_WINNT_VISTA
28 #error "Error: http server APIs are not supported in XP"
29 #endif //_WIN32_WINNT < _WIN32_WINNT_VISTA
30 
31 #include "cpprest/http_listener.h"
32 
33 namespace web { namespace http
34 {
35 namespace experimental {
36 namespace details
37 {
38 
43 {
44 public:
45 
49  virtual ~http_server() { };
50 
54  virtual pplx::task<void> start() = 0;
55 
60 
65 
69  virtual pplx::task<void> stop() = 0;
70 
76  virtual pplx::task<void> respond(http::http_response response) = 0;
77 };
78 
79 } // namespace details
80 } // namespace experimental
81 }} // namespace web::http
virtual ~http_server()
Release any held resources.
Definition: http_server.h:49
Represents an HTTP response.
Definition: http_msg.h:383
virtual pplx::task< void > respond(http::http_response response)=0
Asynchronously sends the specified http response.
The web namespace contains functionality common to multiple protocols like HTTP and WebSockets...
Definition: base_uri.h:37
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: pplxtasks.h:4173
virtual pplx::task< void > start()=0
Start listening for incoming requests.
virtual pplx::task< void > unregister_listener(_In_ web::http::experimental::listener::details::http_listener_impl *pListener)=0
Unregisters an http listener.
virtual pplx::task< void > stop()=0
Stop processing and listening for incoming requests.
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
virtual pplx::task< void > register_listener(_In_ web::http::experimental::listener::details::http_listener_impl *pListener)=0
Registers an http listener.