Commit c81dace7 authored by Jeppe Pihl's avatar Jeppe Pihl

revert unrelated changes and fix remaining warnings

parent 17712121
......@@ -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;
......
......@@ -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();
}
......@@ -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());
......
......@@ -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;
}
......
......@@ -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.
......
......@@ -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!");
}
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment