Code Monkey home page Code Monkey logo

tonic-web-wasm-client's Introduction

tonic-web-wasm-client

Rust implementation of grpc-web protocol that allows using tonic in browsers via webassembly.

Usage

To use tonic-web-wasm-client, you need to add the following to your Cargo.toml:

[dependencies]
tonic-web-wasm-client = "0.5"

Example

To use tonic gRPC clients in browser, compile your code with tonic's transport feature disabled (this will disable the default transport layer of tonic). Then initialize the query client as follows:

use tonic_web_wasm_client::Client;

let base_url = "http://localhost:9001"; // URL of the gRPC-web server
let query_client = QueryClient::new(Client::new(base_url)); // `QueryClient` is the client generated by tonic

let response = query_client.status().await; // Execute your queries the same way as you do with defaule transport layer

Building

Since tonic-web-wasm-client is primarily intended for use in browsers, a crate that uses tonic-web-wasm-client can only be built for wasm32 target architectures:

cargo build --target wasm32-unknown-unknown

Other option is to create a .cargo/config.toml in your crate repository and add a build target there:

[build]
target = "wasm32-unknown-unknown"

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

tonic-web-wasm-client's People

Contributors

devashishdxt avatar nappa85 avatar kaiyohugo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.