api

package
v0.0.0-...-48dec25 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2017 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondWithError

func RespondWithError(w http.ResponseWriter, s int, j JSONError)

RespondWithError writes the error to the response writer

Types

type Config

type Config struct {
	Host              string
	Port              int
	APIPort           int
	ToxyAddress       string
	ToxyAPIPort       int
	ToxyPathSeparator string
	UpstreamURL       string
}

Config for ShrikeServer

type JSONError

type JSONError struct {
	Status  string `json:"string"`
	Message string `json:"message"`
}

JSONError is a simple error data structure

func (*JSONError) Bytes

func (j *JSONError) Bytes() []byte

Bytes for passing to http.ResponseWriter.Write()

type Route

type Route struct {
	Prefix string `json:"prefix"`
}

Route holds information about the routing of a request

type RouteModify

type RouteModify struct {
	Enabled bool `json:"enabled"`
}

RouteModify holds information for updating a proxy on a route

type RouteWithProxy

type RouteWithProxy struct {
	Route Route       `json:"route"`
	Toxy  *toxy.Proxy `json:"toxy"`
}

RouteWithProxy has the proxy and path information to show clients

type ShrikeServer

type ShrikeServer struct {
	ProxyStore *store.ProxyStore
	// contains filtered or unexported fields
}

ShrikeServer is the main Shrike server. Usage: server := api.New(..args) server.Listen()

func New

func New(c Config) *ShrikeServer

New Shrike Server.

func (*ShrikeServer) AddProxy

func (s *ShrikeServer) AddProxy(w http.ResponseWriter, req *http.Request)

AddProxy cfg to Toxiproxy.

func (*ShrikeServer) CreateToxic

func (s *ShrikeServer) CreateToxic(w http.ResponseWriter, req *http.Request)

CreateToxic on the given route

func (*ShrikeServer) DeleteRoute

func (s *ShrikeServer) DeleteRoute(w http.ResponseWriter, req *http.Request)

DeleteRoute removes a route from the proxy

func (*ShrikeServer) DeleteToxic

func (s *ShrikeServer) DeleteToxic(w http.ResponseWriter, req *http.Request)

DeleteToxic from the proxy

func (*ShrikeServer) GetProxies

func (s *ShrikeServer) GetProxies(w http.ResponseWriter, req *http.Request)

GetProxies gets proxies from Toxiproxy and maps with the routes we match from.

func (*ShrikeServer) GetRoute

func (s *ShrikeServer) GetRoute(w http.ResponseWriter, req *http.Request)

GetRoute gets proxies from Toxiproxy and maps with the routes we match from.

func (*ShrikeServer) GetToxic

func (s *ShrikeServer) GetToxic(w http.ResponseWriter, req *http.Request)

GetToxic from the proxy

func (*ShrikeServer) GetToxics

func (s *ShrikeServer) GetToxics(w http.ResponseWriter, req *http.Request)

GetToxics for the given route.

func (*ShrikeServer) Listen

func (s *ShrikeServer) Listen()

Listen on all the appropriate ports

func (*ShrikeServer) Proxy

func (s *ShrikeServer) Proxy(w http.ResponseWriter, req *http.Request)

Proxy requests via Toxiproxy proxies or the upstream server if no match.

func (*ShrikeServer) RemoveAllRoutes

func (s *ShrikeServer) RemoveAllRoutes(w http.ResponseWriter, req *http.Request)

RemoveAllRoutes removes all routes. A hard reset on everything.

func (*ShrikeServer) ResetToxics

func (s *ShrikeServer) ResetToxics(w http.ResponseWriter, req *http.Request)

ResetToxics removes toxics from all Routes and reenables all Route proxies

func (*ShrikeServer) UpdateRoute

func (s *ShrikeServer) UpdateRoute(w http.ResponseWriter, req *http.Request)

UpdateRoute in the proxy

func (*ShrikeServer) UpdateToxic

func (s *ShrikeServer) UpdateToxic(w http.ResponseWriter, req *http.Request)

UpdateToxic in the proxy

Jump to

Keyboard shortcuts

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