gateway

package module
v0.0.0-...-c13ee6f Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

API Gateway

用途

Web APIへのリクエストをフォワードするゲートウェイサービスを構築するためのライブラリです。Goでは動的にデータソースを入れ替えることができないため、mainパッケージ内で静的にプラグインを切り替える思想で設計されています。

cmd/localredisgateway

localhost内で起動することを目的に組み合わせられたエントリーポイントです。データソースにはRedisを利用します。

環境変数の設定
  • LOG_PATH
    • ログファイル(CSV形式)の出力先パス
    • デフォルト: ./log.csv
  • REDIS_HOST
    • redisのホストアドレス
    • デフォルト: localhost
  • REDIS_PORT
    • redisのlistenポート
    • デフォルト: 6379
cmd/localdynamogateway

dynamoDBの場合

  • DYNAMO_TABLE_API_FORWARDING
    • APIルーティングを管理するテーブル名
  • DYNAMO_ENDPOINT

source env.shでローカル実行用の環境変数を読み込むことが出来ます。

ログファイルは各列に日付(RFC3339形式)、APIキー、APIのパスをこの順で含んだCSV形式で作成されます。

実行

Getting Startedを参照ください。

Data model

name type memo example
api_key string key
path string test
forward_url string http://test-server:3333/welcome

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(t *testing.T, commands ...string)

func Teardown

func Teardown(t *testing.T, commands ...string)

Types

type DefaultHandler

type DefaultHandler struct {
	Appender   logger.Appender
	DataSource datasource.DataSource
}

func (DefaultHandler) Handle

func (h DefaultHandler) Handle(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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