// fromHTTP panics with an httputil value on failure
176903
func (r *ClaimsRequest) fromHTTP(req *http.Request) {
	r.Permanode = httputil.MustGetBlobRef(req, "permanode")
	r.AttrFilter = req.FormValue("attrFilter")
}
1225320
func FromError(err error) *Error {
	apiErr, ok := err.(*Error)
	if ok {
		return apiErr
	}

	return NewError(errors.InternalServerError, "Internal Server Error")
}
769710
func (s *SearchService) From(from int) *SearchService {
	s.searchSource = s.searchSource.From(from)
	return s
}
54783
func (r *Request) fromJSON(j *updateRequestJSON) error {

	r.ID = j.ID
	r.Header.Version = j.ProtocolVersion

	var err error
	if j.Data != "" {
		r.data, err = hexutil.Decode(j.Data)
		if err != nil {
			return NewError(ErrInvalidValue, "Cannot decode data")
		}
	}

	if j.Signature != "" {
		sigBytes, err := hexutil.Decode(j.Signature)
		if err != nil || len(sigBytes) != signatureLength {
			return NewError(ErrInvalidSignature, "Cannot decode signature")
		}
		r.Signature = new(Signature)
		r.idAddr = r.Addr()
		copy(r.Signature[:], sigBytes)
	}
	return nil
}
197988
func FromChan(ch <-chan *executor.Call) RequestStreamingFunc {
	if ch == nil {
		// avoid blocking forever if we're handed a nil chan
		return func() *executor.Call { return nil }
	}
	return func() *executor.Call {
		if m, ok := <-ch; ok {
			return m
		}
		return nil
	}
}
641420
func (c *UsersProfileSetCall) FromValues(v url.Values) error {
	var tmp UsersProfileSetCall
	if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
		tmp.name = raw
	}
	if raw := strings.TrimSpace(v.Get("profile")); len(raw) > 0 {
		if err := tmp.profile.Decode(raw); err != nil {
			return errors.Wrap(err, `failed to decode value "profile"`)
		}
	}
	if raw := strings.TrimSpace(v.Get("user")); len(raw) > 0 {
		tmp.user = raw
	}
	if raw := strings.TrimSpace(v.Get("value")); len(raw) > 0 {
		tmp.value = raw
	}
	*c = tmp
	return nil
}
1353762
func FromStatusCode(statusCode int, format string, args ...interface{}) error {
	msg := fmt.Sprintf(format, args...)
	switch statusCode {
	case http.StatusNotFound:
		return NewNotFoundErrorFromString(msg)
	case http.StatusBadRequest:
		return NewBadParameterErrorFromString(msg)
	case http.StatusConflict:
		return NewVersionConflictError(msg)
	case http.StatusUnauthorized:
		return NewUnauthorizedError(msg)
	case http.StatusForbidden:
		return NewForbiddenError(msg)
	default:
		return NewInternalErrorFromString(msg)
	}
}
946873
func (c *GroupsSetPurposeCall) FromValues(v url.Values) error {
	var tmp GroupsSetPurposeCall
	if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
		tmp.channel = raw
	}
	if raw := strings.TrimSpace(v.Get("purpose")); len(raw) > 0 {
		tmp.purpose = raw
	}
	*c = tmp
	return nil
}
877975
func (s *UpdateByQueryService) From(from int) *UpdateByQueryService {
	s.from = &from
	return s
}
429206
func FromURL(u *url.URL, forward Dialer) (Dialer, error) {
	var auth *Auth
	if u.User != nil {
		auth = new(Auth)
		auth.User = u.User.Username()
		if p, ok := u.User.Password(); ok {
			auth.Password = p
		}
	}

	switch u.Scheme {
	case "socks5":
		return SOCKS5("tcp", u.Host, auth, forward)
	}

	// If the scheme doesn't match any of the built-in schemes, see if it
	// was registered by another package.
	if proxySchemes != nil {
		if f, ok := proxySchemes[u.Scheme]; ok {
			return f(u, forward)
		}
	}

	return nil, errors.New("proxy: unknown scheme: " + u.Scheme)
}
262129
func FromString(str string) (UUID, error) {
	u := UUID{}

	err := u.SetString(str)

	return u, err
}
384939
func (m *Message) FromProto(p proto.Message) error {
	ptr := reflect.ValueOf(p)
	if ptr.Type() != m.typ.Type() {
		return fmt.Errorf("bad message type: got %s, expect %s", ptr.Type(), m.typ.Type())
	}

	msg := ptr.Elem()
	for name, fd := range m.typ.fields {
		// Get the field's value from the proto message as reflect.Value. For unused
		// oneof alternatives this is an invalid zero value, we skip them right
		// away. For other fields it is reflect.Value (of fd.typ type) that MAY be
		// nil inside (for unset fields). toStarlarkValue converts such values to
		// starlark.None.
		val := fd.onProtoReflection(msg, reflectFromProto)
		if !val.IsValid() {
			continue
		}
		// Convert the Go value to the corresponding Starlark value and assign it to
		// the field in 'm'.
		sv, err := toStarlarkValue(val)
		if err != nil {
			return fmt.Errorf("cannot recognize value of field %s: %s", name, err)
		}
		if err := m.SetField(name, sv); err != nil {
			return err
		}
	}

	return nil
}
679242
func FromMap(val map[string]interface{}) context.Context {
	return context.WithValue(context.Background(), constants.PropagateCtxKey, val)
}
776838
func (c *UsergroupsCreateCall) FromValues(v url.Values) error {
	var tmp UsergroupsCreateCall
	if raw := strings.TrimSpace(v.Get("channels")); len(raw) > 0 {
		tmp.channels = raw
	}
	if raw := strings.TrimSpace(v.Get("description")); len(raw) > 0 {
		tmp.description = raw
	}
	if raw := strings.TrimSpace(v.Get("handle")); len(raw) > 0 {
		tmp.handle = raw
	}
	if raw := strings.TrimSpace(v.Get("include_count")); len(raw) > 0 {
		parsed, err := strconv.ParseBool(raw)
		if err != nil {
			return errors.Wrap(err, `failed to parse boolean value "include_count"`)
		}
		tmp.includeCount = parsed
	}
	if raw := strings.TrimSpace(v.Get("name")); len(raw) > 0 {
		tmp.name = raw
	}
	*c = tmp
	return nil
}
710137
func (pub *PublicKey) FromBytes(b []byte) (err error) {
	/* See Certicom SEC1 2.3.4, pg. 11 */

	if len(b) < 33 {
		return fmt.Errorf("Invalid public key bytes length %d, expected at least 33.", len(b))
	}

	if b[0] == 0x02 || b[0] == 0x03 {
		/* Compressed public key */

		if len(b) != 33 {
			return fmt.Errorf("Invalid public key bytes length %d, expected 33.", len(b))
		}

		P, err := secp256k1.Decompress(new(big.Int).SetBytes(b[1:33]), uint(b[0]&0x1))
		if err != nil {
			return fmt.Errorf("Invalid compressed public key bytes, decompression error: %v", err)
		}

		pub.X = P.X
		pub.Y = P.Y

	} else if b[0] == 0x04 {
		/* Uncompressed public key */

		if len(b) != 65 {
			return fmt.Errorf("Invalid public key bytes length %d, expected 65.", len(b))
		}

		pub.X = new(big.Int).SetBytes(b[1:33])
		pub.Y = new(big.Int).SetBytes(b[33:65])

		/* Check that the point is on the curve */
		if !secp256k1.IsOnCurve(pub.Point) {
			return fmt.Errorf("Invalid public key bytes: point not on curve.")
		}

	} else {
		return fmt.Errorf("Invalid public key prefix byte 0x%02x, expected 0x02, 0x03, or 0x04.", b[0])
	}

	return nil
}
323236
func (c *GroupsHistoryCall) FromValues(v url.Values) error {
	var tmp GroupsHistoryCall
	if raw := strings.TrimSpace(v.Get("channel")); len(raw) > 0 {
		tmp.channel = raw
	}
	if raw := strings.TrimSpace(v.Get("count")); len(raw) > 0 {
		parsed, err := strconv.ParseInt(raw, 10, 64)
		if err != nil {
			return errors.Wrap(err, `failed to parse integer value "count"`)
		}
		tmp.count = int(parsed)
	}
	if raw := strings.TrimSpace(v.Get("inclusive")); len(raw) > 0 {
		parsed, err := strconv.ParseBool(raw)
		if err != nil {
			return errors.Wrap(err, `failed to parse boolean value "inclusive"`)
		}
		tmp.inclusive = parsed
	}
	if raw := strings.TrimSpace(v.Get("latest")); len(raw) > 0 {
		tmp.latest = raw
	}
	if raw := strings.TrimSpace(v.Get("oldest")); len(raw) > 0 {
		tmp.oldest = raw
	}
	if raw := strings.TrimSpace(v.Get("unreads")); len(raw) > 0 {
		parsed, err := strconv.ParseBool(raw)
		if err != nil {
			return errors.Wrap(err, `failed to parse boolean value "unreads"`)
		}
		tmp.unreads = parsed
	}
	*c = tmp
	return nil
}
1084705
func (s *Server) InitializeHTTP() {
	mux := web.New()
	s.Handler = mux

	mux.Get("/metadata", func(w http.ResponseWriter, r *http.Request) {
		s.idpConfigMu.RLock()
		defer s.idpConfigMu.RUnlock()
		s.IDP.ServeMetadata(w, r)
	})
	mux.Handle("/sso", func(w http.ResponseWriter, r *http.Request) {
		s.idpConfigMu.RLock()
		defer s.idpConfigMu.RUnlock()
		s.IDP.ServeSSO(w, r)
	})

	mux.Handle("/login", s.HandleLogin)
	mux.Handle("/login/:shortcut", s.HandleIDPInitiated)
	mux.Handle("/login/:shortcut/*", s.HandleIDPInitiated)

	mux.Get("/services/", s.HandleListServices)
	mux.Get("/services/:id", s.HandleGetService)
	mux.Put("/services/:id", s.HandlePutService)
	mux.Post("/services/:id", s.HandlePutService)
	mux.Delete("/services/:id", s.HandleDeleteService)

	mux.Get("/users/", s.HandleListUsers)
	mux.Get("/users/:id", s.HandleGetUser)
	mux.Put("/users/:id", s.HandlePutUser)
	mux.Delete("/users/:id", s.HandleDeleteUser)

	mux.Get("/sessions/", s.HandleListSessions)
	mux.Get("/sessions/:id", s.HandleGetSession)
	mux.Delete("/sessions/:id", s.HandleDeleteSession)

	mux.Get("/shortcuts/", s.HandleListShortcuts)
	mux.Get("/shortcuts/:id", s.HandleGetShortcut)
	mux.Put("/shortcuts/:id", s.HandlePutShortcut)
	mux.Delete("/shortcuts/:id", s.HandleDeleteShortcut)
}