func CoerceType(s string) interface{} {
	if u, err := strconv.Unquote(s); err == nil {
		if u != s {
			return u
		}
	}
	if i, err := strconv.ParseInt(s, 10, 0); err == nil {
		return i
	}
	if d, err := strconv.ParseFloat(s, 64); err == nil {
		return d
	}
	if s == "false" {
		return false
	}
	if s == "true" {
		return true
	}
	if s == "" {
		return nil
	}
	return s
}
CoerceType coerces typed value from string
package middleware
import (
	"fmt"
	"net/http"
	"strconv"
	"strings"
	"github.com/optimizely/agent/pkg/optimizely"
	"github.com/optimizely/go-sdk/pkg/config"
	"github.com/go-chi/render"
	"github.com/rs/zerolog"
	"github.com/rs/zerolog/log"
)
type ErrorResponse struct {
	Error string `json:"error"`
}
func GetOptlyClient(r *http.Request) (*optimizely.OptlyClient, error) {
	optlyClient, ok := r.Context().Value(OptlyClientKey).(*optimizely.OptlyClient)
	if !ok || optlyClient == nil {
		return nil, fmt.Errorf("optlyClient not available")
	}
	return optlyClient, nil
}
func GetLogger(r *http.Request) *zerolog.Logger {
	sdkKey := r.Header.Get(OptlySDKHeader)
	reqID := r.Header.Get(OptlyRequestHeader)
	sdkKeySplit := strings.Split(sdkKey, ":")
	logger := log.With().Str("sdkKey", sdkKeySplit[0]).Str("requestId", reqID).Logger()
	return &logger
}
func RenderError(err error, status int, w http.ResponseWriter, r *http.Request) {
	render.Status(r, status)
	render.JSON(w, r, ErrorResponse{Error: err.Error()})
}
func GetFeature(r *http.Request) (*config.OptimizelyFeature, error) {
	feature, ok := r.Context().Value(OptlyFeatureKey).(*config.OptimizelyFeature)
	if !ok {
		return nil, fmt.Errorf("feature not available")
	}
	return feature, nil
}
func GetExperiment(r *http.Request) (*config.OptimizelyExperiment, error) {
	experiment, ok := r.Context().Value(OptlyExperimentKey).(*config.OptimizelyExperiment)
	if !ok {
		return nil, fmt.Errorf("experiment not available")
	}
	return experiment, nil
}