AnCH Framework 0.1
Another C++ Hack Framework
Loading...
Searching...
No Matches
request.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++11 standard
3 Copyright (C) 2020 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <http://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include <vector>
23#include <string>
24#include <memory>
25#include <istream>
26#include <map>
27
28#include "rest/headers.hpp"
29#include "rest/mapperRegistry.hpp"
30
31
32namespace anch::rest {
33
43 class Request {
44 class Builder;
45
46 // Attributes +
47 private:
49 std::string _verb;
50
52 anch::rest::Headers _headers;
53
55 std::string _path;
56
58 std::vector<std::string> _parameters;
59
61 std::shared_ptr<std::istream> _input;
62
65 // Attributes -
66
67 public:
68 // Constructors +
73
79 Request(const Request& res) = delete;
80
84 Request(Request&& other);
85 // Constructors -
86
87 public:
88 // Destructor +
92 virtual ~Request();
93 // Destructor -
94
95 // Methods +
101 static Builder builder();
102 // Methods -
103
104 // Operators +
105 public:
114 // Operators -
115
116 public:
117 // Methods +
123 template<typename T>
125 // Methods -
126
127 public:
128 // Accessors +
134 const std::string& getVerb() const;
135
141 void setVerb(const std::string& verb);
142
149
156 void setHeaders(const anch::rest::Headers& headers);
157
163 std::string getContentType() const;
164
170 void setContentType(const std::string& contentType);
171
177 const std::optional<const std::vector<std::string>> getAccept() const;
178
184 void setAccept(const std::vector<std::string>& accept);
185
191 const std::string& getPath() const;
192
198 void setPath(const std::string& path);
199
205 const std::vector<std::string>& getParameters() const;
206
212 void setParameters(const std::vector<std::string>& parameters);
213 // Accessors -
214
215 };
216
217
228
229 // Attributes +
230 private:
232 Request _request;
233 // Attributes -
234
235 public:
236 // Constructors +
241
248 // Constructors -
249
250 public:
251 // Destructor +
255 virtual ~Builder();
256 // Destructor -
257
258
259 public:
260 // Methods +
261 Builder path(const std::string& path);
262 Builder verb(const std::string& verb);
263
272 Builder header(const std::string& name, const std::string& value);
273
282 Builder header(const std::string& name, const std::vector<std::string>& values);
283
293
301 Builder contentType(const std::string& contentType);
302
310 Builder accept(const std::string& mediaType);
311
319 Builder accept(const std::vector<std::string>& mediaTypes);
320
327 // Methods -
328
329 };
330
331} // anch::rest
332
333#include "rest/impl/request.hpp"
HTTP headers.
Definition headers.hpp:44
Definition mapperRegistry.hpp:49
HTTP request builder.
Definition request.hpp:227
Builder accept(const std::vector< std::string > &mediaTypes)
Builder contentType(const std::string &contentType)
Builder accept(const std::string &mediaType)
Builder header(const std::string &name, const std::vector< std::string > &values)
Builder(Builder &&builder)
Builder header(const std::string &name, const std::string &value)
Builder headers(const anch::rest::Headers &headers)
Request(const Request &res)=delete
void setVerb(const std::string &verb)
void setContentType(const std::string &contentType)
std::string getContentType() const
void setHeaders(const anch::rest::Headers &headers)
Request & operator=(Request &&other)
const std::optional< const std::vector< std::string > > getAccept() const
void setAccept(const std::vector< std::string > &accept)
Request(Request &&other)
void setParameters(const std::vector< std::string > &parameters)
const anch::rest::Headers & getHeaders() const
void setPath(const std::string &path)
const std::vector< std::string > & getParameters() const
const std::string & getPath() const
static Builder builder()
const std::string & getVerb() const