apisix

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2020 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteRoute

func DeleteRoute(route *v1.Route) error

func DeleteSsl

func DeleteSsl(ssl *v1.Ssl) error

func DeleteUpstream

func DeleteUpstream(upstream *v1.Upstream) error

func FindCurrentRoute

func FindCurrentRoute(route *v1.Route) (*v1.Route, error)

FindCurrentRoute find current route in memDB

func FindCurrentService

func FindCurrentService(group, name, fullName string) (*v1.Service, error)

FindCurrentService find service from memDB, if Not Found, find service from apisix

func FindCurrentUpstream

func FindCurrentUpstream(group, name, fullName string) (*v1.Upstream, error)

FindCurrentUpstream find upstream from memDB, if Not Found, find upstream from apisix

func Get

func Get(url string) ([]byte, error)

func ListRoute

func ListRoute(group string) ([]*v1.Route, error)

ListRoute list route from etcd , convert to v1.Route

func ListService

func ListService(group string) ([]*v1.Service, error)

ListUpstream list upstream from etcd , convert to v1.Upstream

func ListSsl

func ListSsl(group string) ([]*v1.Ssl, error)

ListSsl list ssl from etcd , convert to v1.Upstream

func ListUpstream

func ListUpstream(group string) ([]*v1.Upstream, error)

ListUpstream list upstream from etcd , convert to v1.Upstream

func PatchNodes

func PatchNodes(upstream *v1.Upstream, nodes []*v1.Node) error

func UpdateRoute

func UpdateRoute(route *v1.Route) error

func UpdateUpstream

func UpdateUpstream(upstream *v1.Upstream) error

Types

type Cors

type Cors struct {
	Origins []string `json:"origins,omitempty"`
	Headers []string `json:"headers,omitempty"`
	Methods []string `json:"methods,omitempty"`
	MaxAge  int64    `json:"max_age,omitempty"`
}

Cors

func BuildCors

func BuildCors(enable bool, originStr, headerStr, methodStr *string, maxAge *int64) *Cors

BuildCors

type ErrorResponse

type ErrorResponse struct {
	Cause     string `json:"cause"`
	Index     int64  `json:"index"`
	ErrorCode int64  `json:"errorCode"`
	Message   string `json:"message"`
}

type Event

type Event struct {
	Method string               // ADD UPDATE DELETE
	Kind   string               // route service upstream
	Func   func(...interface{}) // callback
}

type IpRestriction

type IpRestriction struct {
	Whitelist []string `json:"whitelist,omitempty"`
	Blacklist []string `json:"blacklist,omitempty"`
}

ip-restrictio

func BuildIpRestriction

func BuildIpRestriction(whites, blacks *string) *IpRestriction

Convert2IpRestriction build IpRestriction

type Match

type Match struct {
	Host   string   `json:"host,omitempty"`
	Uri    string   `json:"uri,omitempty"`
	Use    string   `json:"use"`
	Key    string   `json:"key"`
	Values []string `json:"values,omitempty"`
}

type Redirect

type Redirect struct {
	RetCode int64  `json:"ret_code"`
	Uri     string `json:"uri"`
}

type Route

type Route struct {
	Key   *string `json:"key"`   // route key
	Value Value   `json:"value"` // route content
}

type RouteRequest

type RouteRequest struct {
	Desc      string      `json:"desc,omitempty"`
	Uri       string      `json:"uri,omitempty"`
	Host      string      `json:"host,omitempty"`
	ServiceId string      `json:"service_id,omitempty"`
	Plugins   *v1.Plugins `json:"plugins,omitempty"`
}

type RouteResponse

type RouteResponse struct {
	Action string `json:"action"`
	Route  Route  `json:"node"`
}

func AddRoute

func AddRoute(route *v1.Route) (*RouteResponse, error)

type RouteSet added in v0.2.2

type RouteSet []Route

func (*RouteSet) UnmarshalJSON added in v0.2.2

func (set *RouteSet) UnmarshalJSON(p []byte) error

RouteSet.UnmarshalJSON implements json.Unmarshaler interface. lua-cjson doesn't distinguish empty array and table, and by default empty array will be encoded as '{}'. We have to maintain the compatibility.

type Routes

type Routes struct {
	Key    string   `json:"key"`
	Routes RouteSet `json:"nodes"`
}

type RoutesResponse

type RoutesResponse struct {
	Routes Routes `json:"node"`
}

type Routex

type Routex struct {
	Rules []Rule `json:"rules,inline"`
}

routex

func BuildRoutex

func BuildRoutex(enable bool, rules []Rule) *Routex

BuildRoutex

type Rule

type Rule struct {
	Priority int64   `json:"priority,omitempty"`
	Upstream string  `json:"upstream"`
	Desc     string  `json:"desc"`
	Matches  []Match `json:"matchs,omitempty"`
}

type Service

type Service struct {
	Key          *string      `json:"key"` // service key
	ServiceValue ServiceValue `json:"value,omitempty"`
}

type ServiceRequest

type ServiceRequest struct {
	Desc       *string     `json:"desc,omitempty"`
	UpstreamId *string     `json:"upstream_id"`
	Plugins    *v1.Plugins `json:"plugins,omitempty"`
}

type ServiceResponse

type ServiceResponse struct {
	Action  string  `json:"action"`
	Service Service `json:"node"`
}

func AddService

func AddService(service *v1.Service) (*ServiceResponse, error)

func UpdateService

func UpdateService(service *v1.Service) (*ServiceResponse, error)

type ServiceSet added in v0.2.2

type ServiceSet []Service

func (*ServiceSet) UnmarshalJSON added in v0.2.2

func (set *ServiceSet) UnmarshalJSON(p []byte) error

UpstreamSet.UnmarshalJSON implements json.Unmarshaler interface. lua-cjson doesn't distinguish empty array and table, and by default empty array will be encoded as '{}'. We have to maintain the compatibility.

type ServiceValue

type ServiceValue struct {
	UpstreamId *string                `json:"upstream_id,omitempty"`
	Plugins    map[string]interface{} `json:"plugins"`
	Desc       *string                `json:"desc,omitempty"`
}

type Services

type Services struct {
	Key      string     `json:"key"` // 用来定位upstreams 列表
	Services ServiceSet `json:"nodes"`
}

type ServicesResponse

type ServicesResponse struct {
	Services Services `json:"node"`
}

type SslList

type SslList struct {
	SslNodes SslSet `json:"nodes"`
}

type SslNode

type SslNode struct {
	Key *string `json:"key"`
	Ssl *v1.Ssl `json:"value"`
}

type SslResponse

type SslResponse struct {
	Action string  `json:"action"`
	Ssl    SslNode `json:"node"`
}

func AddOrUpdateSsl

func AddOrUpdateSsl(ssl *v1.Ssl) (*SslResponse, error)

type SslSet added in v0.2.4

type SslSet []SslNode

func (*SslSet) UnmarshalJSON added in v0.2.4

func (set *SslSet) UnmarshalJSON(p []byte) error

SslSet.UnmarshalJSON implements json.Unmarshaler interface. lua-cjson doesn't distinguish empty array and table, and by default empty array will be encoded as '{}'. We have to maintain the compatibility.

type SslsResponse

type SslsResponse struct {
	Action  string  `json:"action"`
	SslList SslList `json:"node"`
}

type Token

type Token struct {
	IgnoreUri []string `json:"ignore_uri,omitempty"`
}

token

func BuildToken

func BuildToken(enable bool, ignoreUris []string) *Token

BuildToken

type Upstream

type Upstream struct {
	Key           *string       `json:"key"` // upstream key
	UpstreamNodes UpstreamNodes `json:"value"`
}

type UpstreamNodes

type UpstreamNodes struct {
	Nodes  map[string]int64 `json:"nodes"`
	Desc   *string          `json:"desc"` // upstream name  = k8s svc
	LBType *string          `json:"type"` // 负载均衡类型
}

type UpstreamRequest

type UpstreamRequest struct {
	LBType string           `json:"type"`
	HashOn *string          `json:"hash_on,omitempty"`
	Key    *string          `json:"key,omitempty"`
	Nodes  map[string]int64 `json:"nodes"`
	Desc   string           `json:"desc"`
}

{"type":"roundrobin","nodes":{"10.244.10.11:8080":100},"desc":"somesvc"}

type UpstreamResponse

type UpstreamResponse struct {
	Action   string   `json:"action"`
	Upstream Upstream `json:"node"`
}

func AddUpstream

func AddUpstream(upstream *v1.Upstream) (*UpstreamResponse, error)

type UpstreamSet added in v0.2.1

type UpstreamSet []Upstream

func (*UpstreamSet) UnmarshalJSON added in v0.2.1

func (set *UpstreamSet) UnmarshalJSON(p []byte) error

UpstreamSet.UnmarshalJSON implements json.Unmarshaler interface. lua-cjson doesn't distinguish empty array and table, and by default empty array will be encoded as '{}'. We have to maintain the compatibility.

type Upstreams

type Upstreams struct {
	Key       string      `json:"key"` // 用来定位upstreams 列表
	Upstreams UpstreamSet `json:"nodes"`
}

type UpstreamsResponse

type UpstreamsResponse struct {
	Upstreams Upstreams `json:"node"`
}

type Value

type Value struct {
	UpstreamId *string                `json:"upstream_id"`
	ServiceId  *string                `json:"service_id"`
	Plugins    map[string]interface{} `json:"plugins"`
	Host       *string                `json:"host,omitempty"`
	Uri        *string                `json:"uri"`
	Desc       *string                `json:"desc"`
	Methods    []*string              `json:"methods,omitempty"`
}

Jump to

Keyboard shortcuts

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