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
c81dace7
Commit
c81dace7
authored
Aug 27, 2018
by
Jeppe Pihl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert unrelated changes and fix remaining warnings
parent
17712121
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
17 deletions
+22
-17
examples/custom_header.cc
examples/custom_header.cc
+9
-0
examples/hello_server.cc
examples/hello_server.cc
+6
-10
examples/http_server.cc
examples/http_server.cc
+1
-1
include/pistache/net.h
include/pistache/net.h
+2
-2
include/pistache/router.h
include/pistache/router.h
+2
-3
tests/http_client_test.cc
tests/http_client_test.cc
+2
-1
No files found.
examples/custom_header.cc
View file @
c81dace7
...
...
@@ -6,6 +6,15 @@
#include <pistache/net.h>
#include <pistache/http_headers.h>
#include <sys/types.h>
// Quiet a warning about "minor" and "major" being doubly defined.
#ifdef major
#undef major
#endif
#ifdef minor
#undef minor
#endif
using
namespace
Pistache
;
using
namespace
Pistache
::
Http
;
...
...
examples/hello_server.cc
View file @
c81dace7
...
...
@@ -15,24 +15,20 @@ public:
HTTP_PROTOTYPE
(
HelloHandler
)
void
onRequest
(
const
Http
::
Request
&
request
,
Http
::
ResponseWriter
response
)
{
(
void
)
request
;
UNUSED
(
request
)
;
response
.
send
(
Pistache
::
Http
::
Code
::
Ok
,
"Hello World
\n
"
);
}
};
int
main
()
{
Pistache
::
Address
addr
(
Pistache
::
Ipv4
::
any
(),
Pistache
::
Port
(
9080
));
auto
opts
=
Pistache
::
Http
::
Endpoint
::
options
().
threads
(
1
);
auto
opts
=
Pistache
::
Http
::
Endpoint
::
options
()
.
threads
(
1
);
Pistache
::
Http
::
Endpoint
server
(
addr
);
Http
::
Endpoint
server
(
addr
);
server
.
init
(
opts
);
server
.
setHandler
(
Pistache
::
Http
::
make_handler
<
HelloHandler
>
());
server
.
setHandler
(
Http
::
make_handler
<
HelloHandler
>
());
server
.
serve
();
std
::
cout
<<
"Starting server. Test with the following command: "
<<
"
\"
curl http://127.0.0.1:"
<<
addr
.
port
()
<<
"
\"\n
"
;
std
::
cout
<<
"Press Enter to Exit"
<<
'\n'
;
server
.
serveThreaded
();
std
::
cin
.
get
();
server
.
shutdown
();
}
examples/http_server.cc
View file @
c81dace7
...
...
@@ -150,7 +150,7 @@ class MyHandler : public Http::Handler {
}
void
onTimeout
(
const
Http
::
Request
&
req
,
Http
::
ResponseWriter
response
)
{
(
void
)
req
;
UNUSED
(
req
)
;
response
.
send
(
Http
::
Code
::
Request_Timeout
,
"Timeout"
)
.
then
([
=
](
ssize_t
)
{
},
PrintException
());
...
...
include/pistache/net.h
View file @
c81dace7
...
...
@@ -114,8 +114,8 @@ struct Size<const char*> {
template
<
size_t
N
>
struct
Size
<
char
[
N
]
>
{
constexpr
size_t
operator
()(
const
char
(
&
arr
)[
N
])
const
{
UNUSED
(
arr
)
constexpr
size_t
operator
()(
const
char
(
&
)[
N
])
const
{
// We omit the \0
return
N
-
1
;
}
...
...
include/pistache/router.h
View file @
c81dace7
...
...
@@ -67,10 +67,10 @@ struct Route {
Route
(
std
::
string
resource
,
Http
::
Method
method
,
Handler
handler
)
:
resource_
(
std
::
move
(
resource
))
,
method_
(
method
)
,
handler_
(
std
::
move
(
handler
))
,
fragments_
(
Fragment
::
fromUrl
(
resource_
))
{
UNUSED
(
method
)
}
std
::
tuple
<
bool
,
std
::
vector
<
TypedParam
>
,
std
::
vector
<
TypedParam
>>
...
...
@@ -119,7 +119,6 @@ private:
};
std
::
string
resource_
;
Http
::
Method
method_
;
Handler
handler_
;
/* @Performance: since we know that resource_ will live as long as the vector underneath,
* we would benefit from std::experimental::string_view to store fragments.
...
...
@@ -202,7 +201,7 @@ public:
private:
explicit
Request
(
const
Http
::
Request
&
request
,
const
Http
::
Request
&
request
,
std
::
vector
<
TypedParam
>&&
params
,
std
::
vector
<
TypedParam
>&&
splats
);
...
...
tests/http_client_test.cc
View file @
c81dace7
...
...
@@ -13,6 +13,7 @@ struct HelloHandler : public Http::Handler {
void
onRequest
(
const
Http
::
Request
&
request
,
Http
::
ResponseWriter
writer
)
{
UNUSED
(
request
)
writer
.
send
(
Http
::
Code
::
Ok
,
"Hello, World!"
);
}
};
...
...
@@ -51,6 +52,6 @@ TEST(request_builder, multiple_send_test) {
server
.
shutdown
();
client
.
shutdown
();
ASSERT_TRUE
(
response_counter
==
RESPONSE_SIZE
);
}
\ No newline at end of file
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