blob: 2a3bb5b3e0e665134dc7fcfbf0e8ef51daa87bab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "http_server.h"
#include <vespa/vespalib/net/crypto_engine.h>
namespace vespalib {
void
HttpServer::get(Portal::GetRequest req)
{
vespalib::string json_result = _handler_repo.get(req.get_host(), req.get_path(), req.export_params());
if (json_result.empty()) {
req.respond_with_error(404, "Not Found");
} else {
req.respond_with_content("application/json", json_result);
}
}
//-----------------------------------------------------------------------------
HttpServer::HttpServer(int port_in)
: _handler_repo(),
_server(Portal::create(CryptoEngine::get_default(), port_in)),
_root(_server->bind("/", *this))
{
}
HttpServer::~HttpServer()
{
_root.reset();
}
} // namespace vespalib
|