func (c *Client) GetMiddleware(mk engine.MiddlewareKey) (*engine.Middleware, error) { data, err := c.Get(c.endpoint("frontends", mk.FrontendKey.Id, "middlewares", mk.Id), url.Values{}) if err != nil { return nil, err } return engine.MiddlewareFromJSON(data, c.Registry.GetSpec) }
func (n *ng) GetMiddleware(key engine.MiddlewareKey) (*engine.Middleware, error) { mKey := n.path("frontends", key.FrontendKey.Id, "middlewares", key.Id) bytes, err := n.getVal(mKey) if err != nil { return nil, err } return engine.MiddlewareFromJSON([]byte(bytes), n.registry.GetSpec, key.Id) }
func parseMiddlewarePack(v []byte, r *plugin.Registry) (*engine.Middleware, time.Duration, error) { var mp middlewareReadPack if err := json.Unmarshal(v, &mp); err != nil { return nil, 0, err } if len(mp.Middleware) == 0 { return nil, 0, &scroll.MissingFieldError{Field: "Middleware"} } f, err := engine.MiddlewareFromJSON(mp.Middleware, r.GetSpec) if err != nil { return nil, 0, err } var ttl time.Duration if mp.TTL != "" { ttl, err = time.ParseDuration(mp.TTL) if err != nil { return nil, 0, err } } return f, ttl, nil }