Skip to content

Commit d8b6d16

Browse files
Merge pull request #8 from toncenter/develop
Added 404 page and fixed 405 for GET method in jsonRPC endpoint
2 parents 926ceaf + c160434 commit d8b6d16

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

config/static_config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ components_manager:
352352
#
353353
handler-JsonRpc:
354354
path: /api/v2/jsonRPC
355-
method: POST
355+
method: GET,POST
356356
logger: api-v2-jsonrpc
357357
port: $server_port
358358
port#fallback: 8081
@@ -372,6 +372,7 @@ components_manager:
372372
handler-static:
373373
fs-cache-component: fs-cache-main
374374
path: /api/v2/*
375+
not-found-file: /404.json
375376
method: GET
376377

377378
#

ton-http-api/src/handlers/JsonRpcHandler.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ std::string JsonRpcHandler::HandleRequestThrow(
2121
const HttpRequest& request, RequestContext&
2222
) const {
2323
try {
24+
if (request.GetMethod() == userver::server::http::HttpMethod::kGet) {
25+
throw utils::TonlibException("method GET is not supported", 405);
26+
}
2427
auto request_json = userver::formats::json::FromString(request.RequestBody());
2528
auto method = request_json["method"].As<std::string>();
2629
userver::formats::json::Value params = userver::formats::json::MakeObject();

ton-http-api/static/404.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"ok":false,"error":"Not Found","code":404,"@extra":"_"}

0 commit comments

Comments
 (0)