Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
pistache
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
pistache
Commits
45f36f7f
Commit
45f36f7f
authored
Jan 21, 2019
by
Miguel Sacristan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Macro "CUSTOM_HEADER" for very basic HTTP Headers
parent
9b2a7a5b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
10 deletions
+23
-10
include/pistache/http_header.h
include/pistache/http_header.h
+19
-0
src/common/mime.cc
src/common/mime.cc
+1
-1
src/server/router.cc
src/server/router.cc
+1
-1
tests/headers_test.cc
tests/headers_test.cc
+2
-8
No files found.
include/pistache/http_header.h
View file @
45f36f7f
...
...
@@ -552,6 +552,25 @@ private:
std
::
string
ua_
;
};
#define CUSTOM_HEADER(header_name) \
class header_name : public Pistache::Http::Header::Header { \
public: \
NAME(#header_name) \
\
header_name() = default; \
\
explicit header_name(const char* value) \
: value_{value} {} \
\
explicit header_name(const std::string& value) \
: value_(value) {} \
\
void write(std::ostream& os) const final { os << value_; }; \
\
private: \
std::string value_; \
}; \
class
Raw
{
public:
Raw
();
...
...
src/common/mime.cc
View file @
45f36f7f
/* mime.cc
Mathieu Stefani, 29 August 2015
Implementaton of MIME Type parsing
Implementat
i
on of MIME Type parsing
*/
#include <cstring>
...
...
src/server/router.cc
View file @
45f36f7f
...
...
@@ -280,7 +280,7 @@ Pistache::Rest::SegmentTreeNode::findRoute(
}
else
{
// current leaf requested, or empty final optional
if
(
!
optional_
.
empty
())
{
// in case of more than one optional at this point, as it is an
// amb
u
iguity, it is resolved by using the first optional
// ambiguity, it is resolved by using the first optional
auto
optional
=
optional_
.
begin
();
// std::string opt {optional->first.data(), optional->first.length()};
return
optional
->
second
->
findRoute
(
path
,
params
,
splats
);
...
...
tests/headers_test.cc
View file @
45f36f7f
...
...
@@ -8,14 +8,7 @@
using
namespace
Pistache
::
Http
;
class
TestHeader
:
public
Header
::
Header
{
public:
NAME
(
"TestHeader"
);
void
write
(
std
::
ostream
&
os
)
const
override
{
os
<<
"TestHeader"
;
}
};
CUSTOM_HEADER
(
TestHeader
)
TEST
(
headers_test
,
accept
)
{
Header
::
Accept
a1
;
...
...
@@ -336,6 +329,7 @@ TEST(headers_test, add_new_header_test)
ASSERT_FALSE
(
Header
::
Registry
::
instance
().
isRegistered
(
headerName
));
Header
::
Registry
::
instance
().
registerHeader
<
TestHeader
>
();
ASSERT_TRUE
(
TestHeader
::
Name
==
"TestHeader"
);
ASSERT_TRUE
(
Header
::
Registry
::
instance
().
isRegistered
(
headerName
));
const
auto
&
headersList
=
Header
::
Registry
::
instance
().
headersList
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment