• Stars
    star
    215
  • Rank 183,925 (Top 4 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple RPC style APIs with generated clients & servers.

RPC

Simple RPC style APIs with generated clients & servers.

About

All RPC methods are invoked with the POST method, and the RPC method name is placed in the URL path. Input is passed as a JSON object in the body, following a JSON response for the output as shown here:

$ curl -d '{ "project_id": "ping_production" }' https://api.example.com/get_alerts
{
  "alerts": [...]
}

All inputs are objects, all outputs are objects, this improves future-proofing as additional fields can be added without breaking existing clients. This is similar to the approach AWS takes with their APIs.

Commands

There are several commands provided for generating clients, servers, and documentation. Each of these commands accept a -schema flag defaulting to schema.json, see the -h help output for additional usage details.

Clients

  • rpc-dotnet-client generates .NET clients
  • rpc-ruby-client generates Ruby clients
  • rpc-php-client generates PHP clients
  • rpc-elm-client generates Elm clients
  • rpc-go-client generates Go clients
  • rpc-go-types generates Go type definitions
  • rpc-ts-client generates TypeScript clients

Servers

  • rpc-go-server generates Go servers

Documentation

  • rpc-md-docs generates markdown documentation

Schemas

Currently the schemas are loosely a superset of JSON Schema, however, this is a work in progress. See the example schema.

FAQ

Why did you create this project? There are many great options when it comes to building APIs, but to me the most important aspect is simplicity, for myself and for the end user. Simple JSON in, and JSON out is appropriate for 99% of my API work, there's no need for the additional performance provided by alternative encoding schemes, and rarely a need for more complex features such as bi-directional streaming provided by gRPC.
Should I use this in production? Only if you're confident that it supports everything you need, or you're comfortable with forking. I created this project for my work at Apex Software, it may not suit your needs.
Why JSON schemas? I think concise schemas using a DSL are great, until they're a limiting factor. Personally I have no problem with JSON, and it's easy to expand upon when you introduce a new feature, such as inline examples for documentation.
Why doesn't it follow the JSON-RPC spec? I would argue this spec is outdated, there is little reason to support batching at the request level, as HTTP/2 handles this for you.
What does the client output look like? See the Apex Logs Go client for an example, client code is designed to be concise and idiomatic.

GoDoc

Sponsored by my GitHub sponsors:

More Repositories

1

up

Deploy infinitely scalable serverless apps, apis, and sites in seconds to AWS.
Go
8,780
star
2

gh-polls

Polls for user feedback in GitHub issues
Go
1,762
star
3

log

Structured logging package for Go.
Go
1,362
star
4

gateway

Drop-in replacement for Go net/http when running in AWS Lambda & API Gateway
Go
652
star
5

apex-ui

Apex monochrome Atom theme UI.
CSS
412
star
6

up-examples

Example apps, apis, and sites for Up.
HTML
389
star
7

static

The static site anti-framework – general-purpose library, purpose-built commands for various domains
Go
293
star
8

apex-go

Golang runtime for Apex/Lambda.
Go
293
star
9

node-apex

Node.js module that makes AWS Lambda's user experience a little nicer using promises.
JavaScript
279
star
10

actions

GitHub Actions
Go
176
star
11

gui

GitHub readme UI components
CSS
132
star
12

apex-syntax

Apex monochrome Atom theme syntax.
CSS
128
star
13

apex-shell

Interactive shell for executing commands in AWS Lambda containers.
Go
121
star
14

capture

Lambda function to capture a URL as PNG, JPG, or GIF using PhantomJS
JavaScript
108
star
15

httpstat

Higher level HTTP tracing for Go
Go
96
star
16

js

Go packages for JavaScript WASM interoperability in the browser
Go
90
star
17

apex-ui-slim

Apex monochrome Atom theme UI (slim variant)
CSS
74
star
18

svg_to_png

Lambda function to convert SVG to PNG using PhantomJS
JavaScript
71
star
19

logs

Apex Logs client for Go.
Go
61
star
20

apex.run

Apex website
HTML
58
star
21

up.js

Up application companion library for Node and the browser
JavaScript
58
star
22

logs-js

Apex Logs client for Node, Deno, and the browser
TypeScript
38
star
23

logs-cloudwatch

Send your AWS CloudWatch Logs to Apex Logs.
Go
38
star
24

httplog

Go http logger for apex/log.
Go
35
star
25

parsers

Performant Go log format parsers.
Go
31
star
26

apex

Old apex/apex
Go
31
star
27

roadmap

Roadmap for Apex Software products
30
star
28

invoke

Lambda invocation helper functions for Go.
Go
27
star
29

logs-winston

Apex Logs integration for the Node.js Winston logging framework
JavaScript
23
star