Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/k-bx/tonic-web-play


https://github.com/k-bx/tonic-web-play

Last synced: 13 days ago
JSON representation

Awesome Lists containing this project

README

        

# Tonic gRPC-Web attempt

## Setup

Add `127.0.0.1 tonic-web-play.localhost` in your /etc/hosts

## Run

**Server**:

```
$ cargo run --bin server
```

**Client**:

```
$ cargo run --bin client
```

Will run on `http://tonic-web-play.localhost:8301`

## The error

```
➜ tonic-web-play git:(main) ✗ curl --http1.1 -XPOST 'http://tonic-web-play.localhost:8301/ping.Ping/Ping' \
-H 'content-type: application/grpc-web' \
-H 'accept: application/grpc-web+proto' \
--data-raw $'\u0000\u0000\u0000\u0000\u0002\n\u0000' -i
HTTP/1.1 200 OK
content-type: application/grpc-web+proto
grpc-status: 13
grpc-message: Missing%20request%20message.
content-length: 0
date: Fri, 04 Aug 2023 06:31:43 GMT
```

The client output:

```
➜ tonic-web-play git:(main) ✗ cargo run --bin client
Compiling tonic-web-play v0.1.0 (/Users/kon/workspace/tonic-web-play)
Finished dev [unoptimized + debuginfo] target(s) in 1.29s
Running `target/debug/client`
BODY=Body(Full(b"\0\0\0\0\x05\n\x03Bob"))
REQUEST=Request { method: POST, uri: http://tonic-web-play.localhost:8301/ping.Ping/Ping, version: HTTP/1.1, headers: {"content-type": "application/grpc-web", "accept": "application/grpc-web"}, body: Body(Full(b"\0\0\0\0\x05\n\x03Bob")) }
REPLY=PingRsp { message: "Hello Bob!" }
```