Skip to content

add jsonrpc example #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ jobs:
include:
- { name: Windows, os: windows-latest }
- { name: Ubuntu, os: ubuntu-latest }
- { name: MacOS, os: macos-latest }
- { name: MacOS, os: macos-15 }
name: Antora Docs (${{ matrix.name }})
runs-on: ${{ fromJSON(needs.runner-selection.outputs.labelmatrix)[matrix.os] }}
defaults:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ if (BOOST_HTTP_IO_BUILD_TESTS)
set(BOOST_HTTP_IO_UNIT_TEST_LIBRARIES beast url)
endif ()
if (BOOST_HTTP_IO_BUILD_EXAMPLES)
set(BOOST_HTTP_IO_EXAMPLE_LIBRARIES program_options scope url)
set(BOOST_HTTP_IO_EXAMPLE_LIBRARIES json program_options scope url multiprecision)
endif ()
# Complete dependency list
set(BOOST_INCLUDE_LIBRARIES ${BOOST_HTTP_IO_INCLUDE_LIBRARIES} ${BOOST_HTTP_IO_UNIT_TEST_LIBRARIES} ${BOOST_HTTP_IO_EXAMPLE_LIBRARIES})
Expand Down
1 change: 1 addition & 0 deletions example/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ add_subdirectory(visit)
if (OPENSSL_FOUND)
add_subdirectory(burl)
add_subdirectory(get)
add_subdirectory(jsonrpc)
endif ()
1 change: 1 addition & 0 deletions example/client/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
#

build-project burl ;
build-project jsonrpc ;
build-project get ;
build-project visit ;
13 changes: 10 additions & 3 deletions example/client/get/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <boost/asio/append.hpp>
//
// Copyright (c) 2025 Mohammad Nejati
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/cppalliance/http_io
//

#include <boost/asio/connect.hpp>
#include <boost/asio/detached.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/host_name_verification.hpp>
Expand Down Expand Up @@ -437,7 +444,7 @@ main(int argc, char* argv[])
// required configuration services
rts::context rts_ctx;

// Install Parser service
// Install parser service
{
http_proto::response_parser::config cfg;
cfg.body_limit = std::uint64_t(-1);
Expand Down
54 changes: 54 additions & 0 deletions example/client/jsonrpc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#
# Copyright (c) 2025 Mohammad Nejati
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/cppalliance/http_io
#

file(GLOB_RECURSE PFILES CONFIGURE_DEPENDS *.cpp *.hpp
CMakeLists.txt
Jamfile)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX "" FILES ${PFILES})

file(GLOB_RECURSE LIBFILES CONFIGURE_DEPENDS jsonrpc/*.cpp jsonrpc/*.hpp Jamfile)
add_library(http_io_example_client_jsonrpc_lib STATIC ${LIBFILES})

target_compile_definitions(http_io_example_client_jsonrpc_lib
PUBLIC BOOST_ASIO_NO_DEPRECATED)

set_property(TARGET http_io_example_client_jsonrpc_lib
PROPERTY FOLDER "examples")

find_package(OpenSSL REQUIRED)

target_link_libraries(http_io_example_client_jsonrpc_lib
PUBLIC
boost_http_io
boost_url
boost_json
boost_multiprecision
OpenSSL::SSL
OpenSSL::Crypto)

if (WIN32)
target_link_libraries(http_io_example_client_jsonrpc_lib PUBLIC crypt32)
endif()

add_executable(http_io_example_client_jsonrpc_cpp11 cpp11.cpp eth_methods.hpp Jamfile)
target_link_libraries(http_io_example_client_jsonrpc_cpp11
PRIVATE
http_io_example_client_jsonrpc_lib)
set_property(TARGET http_io_example_client_jsonrpc_cpp11
PROPERTY FOLDER "examples")

if (CMAKE_CXX_STANDARD EQUAL 20)
add_executable(http_io_example_client_jsonrpc_cpp20 cpp20.cpp eth_methods.hpp Jamfile)
target_link_libraries(http_io_example_client_jsonrpc_cpp20
PRIVATE
http_io_example_client_jsonrpc_lib)
set_property(TARGET http_io_example_client_jsonrpc_cpp20
PROPERTY FOLDER "examples")
endif ()
39 changes: 39 additions & 0 deletions example/client/jsonrpc/Jamfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#
# Copyright (c) 2025 Mohammad Nejati
#
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#
# Official repository: https://github.com/cppalliance/http_io
#

import ../../../../config/checks/config : requires ;

using openssl ;
import ac ;

project
: requirements
<library>/boost/http_io//boost_http_io
<library>/boost/url//boost_url
<library>/boost/json//boost_json
<library>/boost/multiprecision//boost_multiprecision
<library>/openssl//ssl/<link>shared
<library>/openssl//crypto/<link>shared
<target-os>windows:<library>crypt32
<include>.
;

exe cpp11 :
cpp11.cpp
[ glob jsonrpc/*.cpp ]
;

exe cpp20 :
cpp20.cpp
[ glob jsonrpc/*.cpp ]
: requirements
[ requires
cxx20_hdr_coroutine
]
;
Loading
Loading