This chapter covers
- Getting up and running with Apache Thrift and browser-side JavaScript
- Building browser-based Apache Thrift RPC clients
- Building Node.js-based Apache Thrift servers for web clients
- Adding security features to web-based RPC
Though browsers generally use REST APIs to communicate with backend servers, consuming Apache Thrift RPC interfaces in browsers may also make sense in certain settings. For example, in cases where you have existing Apache Thrift services, it may be easier to consume them directly in the browser rather than creating REST wrapper/gateway services or other intermediate overhead. Apache Thrift can also operate over HTTP/2, HTTP 1.1/1.0, and, for those looking for extreme performance, WebSocket.
Apache Thrift offers two JavaScript libraries, one for Node.js and one for browser use. This chapter introduces the RPC features provided by the browser-based Apache Thrift JavaScript libraries. We’ll set up a frontend JavaScript development environment and build browser-based clients with Apache Thrift. The Apache Thrift browser libraries only support client-side RPC operations, so we’ll use Node.js and the Apache Thrift Node.js libraries on the server side. This chapter assumes that you’re familiar with JavaScript and the basics of web programming.