alternator: use simpler API for registering Alternator's HTTP URLs

We used the Seastar HTTP server's add() method to register URLs to
serve (so-called "routes"), but as suggested by Amnon, when we have
fixed URLs without parameters being path components, it's simpler
to use the put() method to do the same thing - and also results in
slightly less work at run-time to look up these routes.

Signed-off-by: Nadav Har'El <nyh@scylladb.com>
This commit is contained in:
Nadav Har'El
2019-12-26 16:17:38 +02:00
parent 9de26b73a4
commit b262eb5031

View File

@@ -281,8 +281,8 @@ void server::set_routes(routes& r) {
return handle_api_request(std::move(req));
});
r.add(operation_type::POST, url("/"), req_handler);
r.add(operation_type::GET, url("/"), new health_handler);
r.put(operation_type::POST, "/", req_handler);
r.put(operation_type::GET, "/", new health_handler);
// The "/localnodes" request is a new Alternator feature, not supported by
// DynamoDB and not required for DynamoDB compatibility. It allows a
// client to enquire - using a trivial HTTP request without requiring
@@ -294,7 +294,7 @@ void server::set_routes(routes& r) {
// consider this to be a security risk, because an attacker can already
// scan an entire subnet for nodes responding to the health request,
// or even just scan for open ports.
r.add(operation_type::GET, url("/localnodes"), new local_nodelist_handler);
r.put(operation_type::GET, "/localnodes", new local_nodelist_handler);
}
//FIXME: A way to immediately invalidate the cache should be considered,