Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

resgate

> 编程语言
Open source

A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

739 stars0 likes1 views
WebsiteGitHub

About

A Realtime API Gateway used with NATS to build REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

Realtime API Gateway Synchronize Your Clients

Visit Resgate.io for guides, live demos, and resources.


Resgate is a Go project implementing a realtime API gateway for the RES protocol with NATS server as messaging system.

It is a simple server that lets you create REST, real time, and RPC APIs, where all your clients are synchronized seamlessly.

Used for building new REST APIs with real-time functionality, or when creating single page applications using reactive frameworks such as React, Vue.js, or Modapp.

Screen capture from the Book Collection Example. Try out the Live demo version yourself.

How it works

Resgate handles all API requests from your clients, instead of directly exposing your micro-services (represented by Node.js and Java below). Clients will connect to Resgate, using either HTTP or WebSocket, to make requests. These requests are sent to the micro-services over NATS server, and Resgate will keep track on which resource each client has requested.

Whenever there is a change to the data, the responsible micro-service sends an event. Resgate will use this event to both update its own cache, and make sure each subscribing client is kept up-to-date.

Quickstart

If you install Docker, it is easy to run both NATS server and Resgate as containers:

docker network create res
docker run -d --name nats -p 4222:4222 --net res nats
docker run --name resgate -p 8080:8080 --net res resgateio/resgate --nats nats://nats:4222

Both images are small, about 10 MB each.

See Resgate.io - Installation for other ways of installation.

Examples

While Resgate may be used with any language, the examples in this repository are written in Javascript for Node.js, without using any additional library.

  • For Go (golang) examples, see go-res package
  • For C# (NETCore) examples, see RES Service for .NET
Example Description
Hello World Simple service serving a static message.
Edit Text Text field that can be edited by multiple clients concurrently.
Book Collection List of book titles & authors that can be edited by many.
JWT Authentication Showing how JWT tokens can be used for authentication.
Password Authentication Showing authentication with user and password credentials.
Client Session Creating client sessions that survive reloads and reconnects.

Note

All examples are complete with both service and client.

Protocol Specification

For more in depth information on the protocol:

  • RES protocol - Introduction and general terminology
  • RES-Service protocol - How to write services
  • RES-Client protocol - How to write client libraries, if ResClient doesn't fit your needs

Usage

resgate [options]

Server options

Option Description Default value
-n, --nats <url> NATS Server URL nats://127.0.0.1:4222
-i, --addr <host> Bind to HOST address 0.0.0.0
-p, --port <port> HTTP port for client connections 8080
-w, --wspath <path> WebSocket path for clients /
-a, --apipath <path> Web resource path for clients /api/
-r, --reqtimeout <seconds> Timeout duration for NATS requests 3000
-u, --headauth <method> Resource method for header authentication
-t, --wsheadauth <method> Resource method for WebSocket header authentication
-m, --metricsport <port> HTTP port for OpenMetrics connections 0 (disabled)
    --apiencoding <type> Encoding for web resources: json, jsonflat json
    --putmethod <methodName> Call method name mapped to HTTP PUT requests
    --deletemethod <methodName> Call method name mapped to HTTP DELETE requests
    --patchmethod <methodName> Call method name mapped to HTTP PATCH requests
    --wscompression Enable WebSocket per message compression
    --resetthrottle <limit> Limit on parallel requests sent on a system reset 0 (no limit)
    --referencethrottle <limit> Limit on parallel requests sent following references 0 (no limit)
-c, --config <file> Configuration file in JSON format

Security options

Option Description Default value
    --tls Enable TLS for HTTP false
    --tlscert <file> HTTP server certificate file
    --tlskey <file> Private key for HTTP server certificate
    --creds <file> NATS User Credentials file
    --natscert <file> NATS Client certificate file
    --natskey <file> NATS Client certificate key file
    --natsrootca <file> NATS Root CA file(s)
    --alloworigin <origin> Allowed origin(s): *, or ://\[:\] *

Logging options

Option Description
-D, --debug Enable debugging output
-V, --trace Enable trace logging
-DV Debug and trace

Common options

Option Description
-h, --help Show usage message
-v, --version Show version

Configuration

Configuration is a JSON encoded file. If no config file is found at the given path, a new file will be created with default values as follows.

Properties

…

Running Resgate

By design, Resgate will exit if it fails to connect to the NATS server, or if it loses the connection. This is to allow clients to try to reconnect to another Resgate instance and resume from there, and to give Resgate a fresh new start if something went wrong.

A simple bash script can keep it running:

bash
#!/bin/bash
until ./resgate; do
    echo "Resgate exited with code $?.  Restarting.." >&2
    sleep 2
done

Documentation

Visit Resgate.io for documentation and resources.

It has guides on installation, configuration, writing services, scaling, queries, and other useful things. It also contains guides for ResClient when working with frameworks such as React, Vue.js, and Modapp.

Support Resgate

Resgate is an MIT-licensed open source project where development is made possible through community support.

If you'd like help out, please consider:

  • Make a one-time donation via PayPal
  • Become a backer via GitHub Sponsors

Contribution

Any feedback on the protocol and its implementation is highly appreciated!

If you find any issues with the protocol or the gateway, feel free to report them.

If you have created a service library, a client library, or some other tool or utility, please contact me to have it added to the list of resources.

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Goapi-gatewaygogolangmicroservices

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言