Skip to content

Apron-Network/apron-gateway-rust

Repository files navigation

The Rust P2P Gateway for Apron Project

Build

cargo build

Environment setup

Standalone

Bootstrap Node

The bootstrap node can be started with this command.

./target/debug/apron-gateway --secret-key-seed 1

OR

cargo run -- --secret-key-seed 1

Client Node

./target/debug/apron-gateway --secret-key-seed 2 --peer /ip4/127.0.0.1/tcp/2145/p2p/<peer id from bootsrap> --p2p-port 2149 --mgmt-port 8084 --forward-port 8086

Start a new httpbin service on Bootstrap Node

docker run -it --rm -p 8923:80 kennethreitz/httpbin

Register a new service on Bootstrap Node

curl --location --request POST 'http://127.0.0.1:8082/service' \
--header 'Content-Type: application/json' \
--data-raw '{
    "peer_id": "",
    "id" : "httpbin_service",
    "domain_name": "localhost",
     "is_deleted" : false,
    "providers": [
        {
            "id" : "service_provider1",
            "name": "httpbin_service_provider1",
            "desc": "httpbin service provider1",
            "base_url": "localhost:8923",
            "schema": "http"
        }
    ]
}'

The new service will be forward to the whole p2p network. So you can query it from client node.

Query new service from Client Node

curl --location --request GET 'http://127.0.0.1:8084/service'

Query other service from Client Node

curl --location --request GET 'http://127.0.0.1:8084/local'
curl --location --request GET 'http://127.0.0.1:8084/remote'
curl --location --request GET 'http://127.0.0.1:8084/peers'

Test forward service

Http

curl http://127.0.0.1:8086/v1/testkey/anything/foobar

The request is sent following this flow. User-->Client node-->Bootstrap node-->Service Provider.

The response is sent following this flow. Service Provider-->Bootstrap node-->Client node-->User.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages