MCPcopy
hub / github.com/fabiolb/fabio / NewTable

Function NewTable

route/table.go:156–185  ·  view source on GitHub ↗
(b *bytes.Buffer)

Source from the content-addressed store, hash-verified

154}
155
156func NewTable(b *bytes.Buffer) (t Table, err error) {
157 defs, err := Parse(b)
158 if err != nil {
159 return nil, err
160 }
161
162 t = make(Table)
163 for _, d := range defs {
164 switch d.Cmd {
165 case RouteAddCmd:
166 err = t.addRoute(d)
167 case RouteDelCmd:
168 err = t.delRoute(d)
169 case RouteWeightCmd:
170 err = t.weighRoute(d)
171 default:
172 err = fmt.Errorf("route: invalid command: %s", d.Cmd)
173 }
174 if err != nil {
175 return nil, err
176 }
177 }
178
179 // Sort the route table for each hostname
180 for _, h := range t {
181 sort.Sort(h)
182 }
183
184 return t, nil
185}
186
187func NewTableCustom(defs *[]RouteDef) (t Table, err error) {
188

Callers 15

watchBackendFunction · 0.92
TestGracefulShutdownFunction · 0.92
TestTCPDyanmicProxyFunction · 0.92
TestTCPProxyFunction · 0.92
TestProxyStripsPathFunction · 0.92
TestProxyPrependsPathFunction · 0.92
TestProxyHostFunction · 0.92
TestHostRedirectFunction · 0.92
TestPathRedirectFunction · 0.92
TestProxyHTTPSUpstreamFunction · 0.92
TestProxyHTTPSTransportFunction · 0.92

Calls 4

ParseFunction · 0.85
addRouteMethod · 0.80
delRouteMethod · 0.80
weighRouteMethod · 0.80

Tested by 15

TestGracefulShutdownFunction · 0.74
TestTCPDyanmicProxyFunction · 0.74
TestTCPProxyFunction · 0.74
TestProxyStripsPathFunction · 0.74
TestProxyPrependsPathFunction · 0.74
TestProxyHostFunction · 0.74
TestHostRedirectFunction · 0.74
TestPathRedirectFunction · 0.74
TestProxyHTTPSUpstreamFunction · 0.74
TestProxyHTTPSTransportFunction · 0.74