/
route.go
75 lines (72 loc) · 3.09 KB
/
route.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright 2022 The Amesh Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package apisix
// RouteStatus Enumerations.
type RouteStatus int32
const (
RouteDisable RouteStatus = 0
RouteEnable RouteStatus = 1
)
// A Route contains multiple parts but basically can be grouped
// into three:
// 1). Route match, fields like uris, hosts, remote_addrs are the
// predicates to indicate whether a request can hit the route.
// 2). Route action, upstream_id specifies the backend upstream
// object, which guides Apache APISIX how to route request.
// 3). Plugins, plugins will run before/after the route action,
// some plugins are "terminated" so may be requests will be returned
// on the APISIX side (like authentication failures).
type Route struct {
// URI array used to do the route match.
// At least one item should be configured and each of them cannot be
// duplicated.
Uris []string `json:"uris,omitempty"`
// The route name, it's useful for the logging but it's not required.
Name string `json:"name,omitempty"`
// The route id.
Id string `json:"id,omitempty"`
// Textual descriptions used to describe the route use.
Desc string `json:"desc,omitempty"`
// Priority of this route, used to decide which route should be used when
// multiple routes contains same URI.
// Larger value means higher priority. The default value is 0.
Priority int32 `json:"priority,omitempty"`
// HTTP Methods used to do the route match.
Methods []string `json:"methods,omitempty"`
// Host array used to do the route match.
Hosts []string `json:"hosts,omitempty"`
// Remote address array used to do the route match.
RemoteAddrs []string `json:"remote_addrs,omitempty"`
// Nginx vars used to do the route match.
Vars []*Var `json:"vars,omitempty"`
// Embedded plugins.
Plugins map[string]interface{} `json:"plugins,omitempty"`
// The referred service id.
ServiceId string `json:"service_id,omitempty"`
// The referred upstream id.
UpstreamId string `json:"upstream_id,omitempty"`
// The route status.
Status RouteStatus `json:"status,omitempty"`
// Timeout sets the I/O operations timeouts on the route level.
Timeout *Timeout `json:"timeout,omitempty"`
// enable_websocket indicates whether the websocket proxy is enabled.
EnableWebsocket bool `json:"enable_websocket,omitempty"`
// Labels contains some labels for the sake of management.
Labels map[string]string `json:"labels,omitempty" `
// create_time indicate the create timestamp of this route.
CreateTime int64 `json:"create_time,omitempty"`
// update_time indicate the last update timestamp of this route.
UpdateTime int64 `json:"update_time,omitempty"`
}