Giter Site home page Giter Site logo

ktor-grpcweb's Introduction

Java CI Download

Embedded gRPC Web Proxy for Ktor

An embedded gRPC Web proxy for Java/Kotlin gRPC servers using Ktor as HTTP server.

GRPC is a versatile RPC protocol with good support for many programming languages. Javascript applications running in a browser, however, cannot use the binary gRPC protocol directly, instead the gRPC Web protocol can be used, which offers some features of binary gRPC and uses regular HTTP/1 as transport.

To access a regular gRPC server via the gRPC Web protocol, a proxy is needed to convert protocols. There are only a few such gRPC Web proxies available, a common one is envoy.

In small setups, a dedicated gRPC Web proxy can be avoided with an embedded proxy such as this. This project provides a handler that integrates into the HTTP server Ktor that proxies between gRPC Web calls and an internal or external binary gRPC server.

Features

  • Both gRPC Web and gRPC Web Text protocols are supported
  • CORS support, server responds to CORS preflight OPTION calls and sets headers to allow CORS calls
  • Proxied gRPC server can be in-process or external
  • HTTPS provided by Ktor

Not supported:

  • Routing to multiple gRPC servers

Usage

val channel = InProcessChannelBuilder.forName("my-server").build()
val webServer = embeddedServer(Netty, 40927) {
    routing {
        route("grpcweb") {
            handleGrpcWebCalls(channel)
        }
    }
}
webServer.start()

ktor-grpcweb's People

Contributors

blachris avatar gordonmu avatar

Watchers

 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.