Skip to content

Commit 92b0311

Browse files
committed
add jsonrpc example
1 parent b1264d9 commit 92b0311

File tree

16 files changed

+1403
-5
lines changed

16 files changed

+1403
-5
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ jobs:
11511151
include:
11521152
- { name: Windows, os: windows-latest }
11531153
- { name: Ubuntu, os: ubuntu-latest }
1154-
- { name: MacOS, os: macos-latest }
1154+
- { name: MacOS, os: macos-15 }
11551155
name: Antora Docs (${{ matrix.name }})
11561156
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
11571157
defaults:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ if (BOOST_HTTP_IO_BUILD_TESTS)
7272
set(BOOST_HTTP_IO_UNIT_TEST_LIBRARIES beast url)
7373
endif ()
7474
if (BOOST_HTTP_IO_BUILD_EXAMPLES)
75-
set(BOOST_HTTP_IO_EXAMPLE_LIBRARIES program_options scope url)
75+
set(BOOST_HTTP_IO_EXAMPLE_LIBRARIES json program_options scope url multiprecision)
7676
endif ()
7777
# Complete dependency list
7878
set(BOOST_INCLUDE_LIBRARIES ${BOOST_HTTP_IO_INCLUDE_LIBRARIES} ${BOOST_HTTP_IO_UNIT_TEST_LIBRARIES} ${BOOST_HTTP_IO_EXAMPLE_LIBRARIES})

example/client/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ add_subdirectory(visit)
1414
if (OPENSSL_FOUND)
1515
add_subdirectory(burl)
1616
add_subdirectory(get)
17+
add_subdirectory(jsonrpc)
1718
endif ()

example/client/Jamfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
#
99

1010
build-project burl ;
11+
build-project jsonrpc ;
1112
build-project get ;
1213
build-project visit ;

example/client/get/main.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
#include <boost/asio/append.hpp>
1+
//
2+
// Copyright (c) 2025 Mohammad Nejati
3+
//
4+
// Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
//
7+
// Official repository: https://github.com/cppalliance/http_io
8+
//
9+
210
#include <boost/asio/connect.hpp>
3-
#include <boost/asio/detached.hpp>
411
#include <boost/asio/io_context.hpp>
512
#include <boost/asio/ip/tcp.hpp>
613
#include <boost/asio/ssl/host_name_verification.hpp>
@@ -437,7 +444,7 @@ main(int argc, char* argv[])
437444
// required configuration services
438445
rts::context rts_ctx;
439446

440-
// Install Parser service
447+
// Install parser service
441448
{
442449
http_proto::response_parser::config cfg;
443450
cfg.body_limit = std::uint64_t(-1);

example/client/jsonrpc/CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#
2+
# Copyright (c) 2025 Mohammad Nejati
3+
#
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Official repository: https://github.com/cppalliance/http_io
8+
#
9+
10+
file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS *.cpp *.hpp
11+
CMakeLists.txt
12+
Jamfile)
13+
14+
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${PFILES})
15+
16+
file(GLOB_RECURSE LIBFILES CONFIGURE_DEPENDS lib/*.cpp)
17+
add_library(http_io_example_client_jsonrpc_lib ${LIBFILES})
18+
19+
target_compile_definitions(http_io_example_client_jsonrpc_lib
20+
PUBLIC BOOST_ASIO_NO_DEPRECATED)
21+
22+
set_property(TARGET http_io_example_client_jsonrpc_lib
23+
PROPERTY FOLDER "examples")
24+
25+
find_package(OpenSSL REQUIRED)
26+
27+
target_link_libraries(http_io_example_client_jsonrpc_lib
28+
PUBLIC
29+
boost_http_io
30+
boost_url
31+
boost_json
32+
boost_multiprecision
33+
OpenSSL::SSL
34+
OpenSSL::Crypto)
35+
36+
if (WIN32)
37+
target_link_libraries(http_io_example_client_jsonrpc_lib PUBLIC crypt32)
38+
endif()
39+
40+
add_executable(http_io_example_client_jsonrpc_cpp11 cpp11.cpp)
41+
target_link_libraries(http_io_example_client_jsonrpc_cpp11
42+
http_io_example_client_jsonrpc_lib)
43+
set_property(TARGET http_io_example_client_jsonrpc_cpp11
44+
PROPERTY FOLDER "examples")
45+
46+
if (CMAKE_CXX_STANDARD EQUAL 20)
47+
add_executable(http_io_example_client_jsonrpc_cpp20 cpp20.cpp)
48+
target_link_libraries(http_io_example_client_jsonrpc_cpp20
49+
http_io_example_client_jsonrpc_lib)
50+
set_property(TARGET http_io_example_client_jsonrpc_cpp20
51+
PROPERTY FOLDER "examples")
52+
endif ()

example/client/jsonrpc/Jamfile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#
2+
# Copyright (c) 2025 Mohammad Nejati
3+
#
4+
# Distributed under the Boost Software License, Version 1.0. (See accompanying
5+
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
#
7+
# Official repository: https://github.com/cppalliance/http_io
8+
#
9+
10+
import ../../../../config/checks/config : requires ;
11+
12+
using openssl ;
13+
import ac ;
14+
15+
project
16+
: requirements
17+
<library>/boost/http_io//boost_http_io
18+
<library>/boost/url//boost_url
19+
<library>/boost/json//boost_json
20+
<library>/boost/multiprecision//boost_multiprecision
21+
<library>/openssl//ssl/<link>shared
22+
<library>/openssl//crypto/<link>shared
23+
<target-os>windows:<library>crypt32
24+
<include>.
25+
;
26+
27+
exe cpp11 :
28+
cpp11.cpp
29+
[ glob lib/*.cpp ]
30+
;
31+
32+
exe cpp20 :
33+
cpp20.cpp
34+
[ glob lib/*.cpp ]
35+
: requirements
36+
[ requires
37+
cxx20_hdr_coroutine
38+
]
39+
;

0 commit comments

Comments
 (0)