Protocol Buffers to HTTP client code generator/converter

Proto2http

Proto2http provides a code generation tool to convert your protocol buffers (.proto) files into invokable HTTP request.

Usage

proto2http -path=your-file.proto -output=../generated_protos/ -baseurl=https://your-api-path.com -target=language-target

See proto2http -help for more detail.

Samples

Converted files from gRPC's official sample HelloWorld.proto invoked with command:

proto2http -path=test.proto -target=browser-ts -baseurl=http://test-api.com/
/**
 * The request message containing the user's name.
 */
type HelloRequest = {
    name: string
}

/**
 * The response message containing the greetings
 */
type HelloReply = {
    message: string
}

/**
 * The greeting service definition.
 */
export class GreeterClient {
    _baseUrl: string
    constructor(baseUrl?: string) {
        if (baseUrl === "" || baseUrl == null) {
            this._baseUrl = "http://test-api.com/";
        } else {
            this._baseUrl = baseUrl;
        }
    }

    /**
     * Sends a greeting
     */
    public async SayHello(input: HelloRequest): Promise<HelloReply> {
        const request = await fetch(
            new URL("SayHello", this._baseUrl).toString(),
            {
                method: "POST",
                headers: {
                    "Content-Type": "application/json",
                    "Accept": "application/json"
                },
                body: JSON.stringify(input),
            }
        );

        const body = await request.json();
        return body;
    }

}

For all client and server samples of router_guide.proto, see this gist.

Installation

Precompiled binary

See RELEASES page.

Available systems: MacOS AMD64, Linux 386, Linux AMD64, Linux ARM, Linux ARM64, Windows 386, Windows AMD64, Windows ARM.

Install it as a Go binary

go install github.com/kodiiing/proto2http@latest

Build from source

You will need Go 1.17+

go build -o proto2http cmd/main.go
mv proto2http /usr/local/bin/proto2http

License

MIT

Similar Resources

🎄 My code for the Advent of Code of year 2021 in Go.

Advent of Code 2021 This repository contains all code that I wrote for the Advent of Code 2021. This year I chose to try and learn Go. Enjoy! Built wi

Dec 9, 2021

Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.

Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.

Graphical small-internet client for windows, linux, MacOS X and BSDs. Supports gemini, http, https, gopher, finger.

Jan 1, 2023

Gore - Simple HTTP client for Go

GoRe (Go Requester) Simple HTTP client for Go Example g := gore.New( gore.With

Jan 21, 2022

Chief Client Go is a cross platform Krunker client written in Go Lang

Chief Client Go Chief Client Go is a client for Mac and Linux written in GoLang Features Ad Blocker Option to use proxy Installation To install this c

Nov 6, 2021

An experiment building a custom binary protocol for a calculator

Overview Implementation of a calculator service built on a custom protocol on top of TCP Details The server is in main.go, and the client is in client

Nov 28, 2021

Refrence implementation of the globaldce protocol

globaldce-toolbox This is the reference implementation of globaldce protocole coded in the go programming language. This project is still experimental

Dec 14, 2022

klaytnBreak - Official golang implementation of the Klaytn protocol

Klaytn Official golang implementation of the Klaytn protocol. Please visit KlaytnDocs for more details on Klaytn design, node operation guides and app

Jan 13, 2022

Random fake data and struct generator for Go.

Faker Random fake data and struct generator for Go. More than 100 generator functions Struct generator Unique data generator Builtin types support Eas

Oct 3, 2022

Random fake data generator written in go

Random fake data generator written in go

Gofakeit Random data generator written in go Features 160+ Functions!!! Concurrent Global Rand Struct Generator Custom Functions Http Server Command L

Jan 1, 2023
Comments
  • Implement proper testing on targets

    Implement proper testing on targets

    Use snapshot testing with the snapshot package from Kodiiing organization.

    Please note that new target implementation should use snapshot testing to verify their output.

PCM converter - Resample part relies on SOXR.

Resample part relies on SOXR. To install make sure you have libsoxr installed, then run: go get -u github.com/ZhangJYd/pcm_convertor example: package

Nov 23, 2021
Serial to Keyboard converter for Polar's card readers

polar-serial-to-keyboard Serial to Keyboard converter for Polar's card readers Configuration This program is intended to be run as a background proces

Dec 17, 2021
Eightbit - A converter to create shitty 8-bit like images

eightbit A converter to create shitty 8-bit like images. Usage To install: go in

Jan 8, 2022
Numtow - Golang number to words converter

numtow golang library to convert number to words. Supported languages: kazakh, e

Dec 31, 2022
T80nxbt - Thurastmaster-T80 to ProCon Converter

t80nxbt Thurastmaster-T80 to ProCon Converter. connection T80----usb----Raspberr

Jan 30, 2022
XSD (XML Schema Definition) parser and Go/C/Java/Rust/TypeScript code generator

xgen Introduction xgen is a library written in pure Go providing a set of functions that allow you to parse XSD (XML schema definition) files. This li

Jan 1, 2023
Jennifer is a code generator for Go

Jennifer Jennifer is a code generator for Go. package main import ( "fmt" . "github.com/dave/jennifer/jen" ) func main() { f := NewFile("m

Dec 25, 2022
General Golang Code Generator

gg gg is a General Golang Code Generator: A Good Game to play with Golang. package main import ( "fmt" . "github.com/Xuanwo/gg" ) func main() {

Jan 7, 2023
Default godoc generator - make your first steps towards better code documentation

godoc-generate Overview godoc-generate is a simple command line tool that generates default godoc comments on all exported types, functions, consts an

Sep 14, 2022
The High Code Framework (low-code for devs)

hof - the high code framework The hof tool tries to remove redundent development activities by using high level designs, code generation, and diff3 wh

Dec 24, 2022