Example #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(response)
}
Example #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([]byte(bytes), key.Id)
}
Example #3
0
func parseFrontendPack(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(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
}