Exemplo n.º 1
0
func (c *Client) GetFrontend(fk engine.FrontendKey) (*engine.Frontend, error) {
	response, err := c.Get(c.endpoint("frontends", fk.Id), url.Values{})
	if err != nil {
		return nil, err
	}
	return engine.FrontendFromJSON(c.Registry.GetRouter(), response)
}
Exemplo n.º 2
0
func (n *ng) GetFrontend(key engine.FrontendKey) (*engine.Frontend, error) {
	frontendKey := n.path("frontends", key.Id, "frontend")

	bytes, err := n.getVal(frontendKey)
	if err != nil {
		return nil, err
	}
	return engine.FrontendFromJSON(n.registry.GetRouter(), []byte(bytes), key.Id)
}
Exemplo n.º 3
0
func parseFrontendPack(router router.Router, v []byte) (*engine.Frontend, time.Duration, error) {
	var fp frontendReadPack
	if err := json.Unmarshal(v, &fp); err != nil {
		return nil, 0, err
	}
	if len(fp.Frontend) == 0 {
		return nil, 0, &scroll.MissingFieldError{Field: "Frontend"}
	}
	f, err := engine.FrontendFromJSON(router, fp.Frontend)
	if err != nil {
		return nil, 0, err
	}

	var ttl time.Duration
	if fp.TTL != "" {
		ttl, err = time.ParseDuration(fp.TTL)
		if err != nil {
			return nil, 0, err
		}
	}
	return f, ttl, nil
}