gateway

command module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2018 License: MIT Imports: 17 Imported by: 0

README

gateway

api gateway for golang http server.

Todos

  • HTTP reverse proxy
  • HTTP Cache, support URI with query param and post form
  • [] Expansion, support leader node and slave
  • [] Permission, RBAC mode
  • [] Ratelimit, token bucket alg

JSON Config file

just run a binary file and do some config so you can just run it easily. proxy config likes: config.proxy.json

{
    "port": 8989,
    "logpath": "./logs",
    "proxy_config": {
        "path_rules": [
            {
                "path": "/gw/name",
                "rewrite_path": "/srv/name",
                "method": "GET",
                "server_name": "srv1",
                "combine_req_cfgs": [],
                "need_combine": false
            },
            {
                "path": "/gw/id",
                "rewrite_path": "/srv/id",
                "method": "GET,POST",
                "server_name": "srv1",
                "combine_req_cfgs": [],
                "need_combine": false
            },
            {
                "path": "/gw/combine",
                "rewrite_path": "",
                "method": "GET",
                "server_name": "",
                "combine_req_cfgs": [
                    {
                        "server_name": "srv1",
                        "path": "/srv/id",
                        "field": "combine_id",
                        "method": "GET"
                    },
                    {
                        "server_name": "srv1",
                        "path": "/srv/name",
                        "field": "combine_name",
                        "method": "POST"
                    }
                ],
                "need_combine": true
            }
        ],
        "server_rules": [
            {
                "prefix": "/srv",
                "server_name": "srv1",
                "need_strip_prefix": false
            },
            {
                "prefix": "/striprefix",
                "server_name": "srv1",
                "need_strip_prefix": true
            }
        ],
        "reverse_server_cfgs": {
            "custom_group1": [
                {
                    "name": "srv1",
                    "prefix": "/srv",
                    "addr": "127.0.0.1:8081",
                    "weight": 5
                },
                {
                    "name": "srv1",
                    "prefix": "/srv",
                    "addr": "127.0.0.1:8082",
                    "weight": 5
                }
            ]
        }
    },
    "cacheno_rules": [
        {
            "regular": "^/api/id$"
        }
    ]
}

server config likes: github.com/yeqown/gateway.server.json

{
    "host": "127.0.0.1",
    "port": "9898"
}

Documentation

Overview

Package main is the entry of github.com/yeqown/gateway

Directories

Path Synopsis
api
example
server1 command
server2 command
Package logger define output to std or file
Package logger define output to std or file
cache
Package cache ...
Package cache ...
httplog
Package httplog to log http request
Package httplog to log http request
proxy
Package proxy ...
Package proxy ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL