Example #1
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            string ogdiAlias = requestContext.RouteData.Values["OgdiAlias"] as string;
            string entitySet = requestContext.RouteData.Values["EntitySet"] as string;
            string remainder = requestContext.RouteData.Values["Remainder"] as string;

            if (!AppSettings.EnabledStorageAccounts.ContainsKey(ogdiAlias))
            {
                // If the requested OgdiAlias for the storage account is not already cached, then refresh the cache.
                // If it is still not in the cache, then this is a bad request.
                AppSettings.RefreshAvailableEndpoints();
                if (!AppSettings.EnabledStorageAccounts.ContainsKey(ogdiAlias))
                {
                    Ogdi.Config.AvailableEndpoint endPoint = AppSettings.GetAvailableEndpointByAccountName(ogdiAlias);
                    if (endPoint == null)
                    {
                        return(new NotFoundHandler());
                    }
                    ogdiAlias = endPoint.alias;
                }
            }

            IHttpHandler HttpHandler = new MainHttpHandler()
            {
                OgdiAlias = ogdiAlias,
                EntitySet = entitySet,
                Remainder = remainder
            };

            return(HttpHandler);
        }
Example #2
0
        public IHttpHandler GetHttpHandler(RequestContext requestContext)
        {
            _azureTableRequestEntityUrl = AppSettings.TableStorageBaseUrl;
            IHttpHandler handlerToReturn = null;

            _isAvailableEndpointsRequest = string.Compare(((Route)requestContext.RouteData.Route).Url, "v1/AvailableEndpoints", true) == 0;
            _remainder = requestContext.RouteData.Values["remainder"] as string;
            _ogdiAlias = requestContext.RouteData.Values["OgdiAlias"] as string;
            _entitySet = requestContext.RouteData.Values["EntitySet"] as string;

            if (!_isAvailableEndpointsRequest)
            {
                if (AppSettings.EnabledStorageAccounts.ContainsKey(_ogdiAlias))
                {
                    handlerToReturn = GetTableStorageProxyHandler();
                }
                else
                {
                    // If the requested OgdiAlias for the storage account is not already cached,
                    // then refresh the cache.  If it is still not in the cache, then this is
                    // a bad request.
                    AppSettings.RefreshAvailableEndpoints();

                    if (AppSettings.EnabledStorageAccounts.ContainsKey(_ogdiAlias))
                    {
                        handlerToReturn = GetTableStorageProxyHandler();
                    }
                    else
                    {
                        //Possile OgdiAlias is acccountName
                        Ogdi.Config.AvailableEndpoint endPoint = AppSettings.GetAvailableEndpointByAccountName(_ogdiAlias);

                        if (endPoint != null)
                        {
                            _ogdiAlias      = endPoint.alias;
                            handlerToReturn = GetTableStorageProxyHandler();
                        }
                        else
                        {
                            handlerToReturn = new NotFoundHandler();
                        }
                    }
                }
            }
            else
            {
                handlerToReturn = GetTableStorageProxyHandler();
            }

            return(handlerToReturn);
        }