func NewDefaultAPIRouter(optlyCache optimizely.Cache, conf config.APIConfig, metricsRegistry *metrics.Registry) http.Handler {
	authProvider := middleware.NewAuth(&conf.Auth)
	if authProvider == nil {
		log.Error().Msg("unable to initialize api auth middleware.")
		return nil
	}
	authHandler := handlers.NewOAuthHandler(&conf.Auth)
	if authHandler == nil {
		log.Error().Msg("unable to initialize api auth handler.")
		return nil
	}
	overrideHandler := handlers.Override
	if !conf.EnableOverrides {
		overrideHandler = forbiddenHandler("Overrides not enabled")
	}
	nStreamHandler := handlers.NotificationEventSteamHandler
	if !conf.EnableNotifications {
		nStreamHandler = forbiddenHandler("Notification stream not enabled")
	}
	mw := middleware.CachedOptlyMiddleware{Cache: optlyCache}
	corsHandler := createCorsHandler(conf.CORS)
	spec := &APIOptions{
		maxConns:        conf.MaxConns,
		metricsRegistry: metricsRegistry,
		configHandler:   handlers.OptimizelyConfig,
		datafileHandler: handlers.GetDatafile,
		activateHandler: handlers.Activate,
		decideHandler:   handlers.Decide,
		overrideHandler: overrideHandler,
		trackHandler:    handlers.TrackEvent,
		sdkMiddleware:   mw.ClientCtx,
		nStreamHandler:  nStreamHandler,
		oAuthHandler:    authHandler.CreateAPIAccessToken,
		oAuthMiddleware: authProvider.AuthorizeAPI,
		corsHandler:     corsHandler,
	}
	return NewAPIRouter(spec)
}
NewDefaultAPIRouter creates a new router with the default backing optimizely.Cache
package routers
import (
	"net/http"
	"github.com/rakyll/statik/fs"
	"github.com/rs/zerolog/log"
	"github.com/optimizely/agent/config"
	"github.com/optimizely/agent/pkg/handlers"
	"github.com/optimizely/agent/pkg/metrics"
	"github.com/optimizely/agent/pkg/middleware"
	"github.com/optimizely/agent/pkg/optimizely"
	_ "github.com/optimizely/agent/statik"  
	"github.com/go-chi/chi"
	chimw "github.com/go-chi/chi/middleware"
	"github.com/go-chi/cors"
	"github.com/go-chi/render"
)
type APIOptions struct {
	maxConns        int
	sdkMiddleware   func(next http.Handler) http.Handler
	metricsRegistry *metrics.Registry
	configHandler   http.HandlerFunc
	datafileHandler http.HandlerFunc
	activateHandler http.HandlerFunc
	decideHandler   http.HandlerFunc
	trackHandler    http.HandlerFunc
	overrideHandler http.HandlerFunc
	nStreamHandler  http.HandlerFunc
	oAuthHandler    http.HandlerFunc
	oAuthMiddleware func(next http.Handler) http.Handler
	corsHandler     func(next http.Handler) http.Handler
}
func forbiddenHandler(message string) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, message, http.StatusForbidden)
	}
}