Exemplo n.º 1
0
        /// <summary>Process the given context.</summary>
        /// <param name="context">The context.</param>
        /// <returns>An asynchronous result that yields a HttpResponseMessage.</returns>
        internal static async Task <HttpResponseMessage> Process(HttpContext context)
        {
            // create our response object
            HttpResponseMessage response = new HttpResponseMessage();

            if (ProcessorUtils.IsOperation(context.Request, out string operationName, out string prevComponent))
            {
                response.StatusCode = System.Net.HttpStatusCode.NotImplemented;
                return(response);
            }

            // get copies of data when we care
            switch (context.Request.Method.ToUpperInvariant())
            {
            case "GET":
                ProcessGet(ref context, ref response);

                break;

            default:
                // tell client we didn't understand
                response.StatusCode = System.Net.HttpStatusCode.NotImplemented;

                break;
            }

            // return the originator response, plus any modifications we've done
            return(response);
        }
        /// <summary>Process the request.</summary>
        /// <param name="context">The context.</param>
        /// <returns>An asynchronous result that yields a HttpResponseMessage.</returns>
        internal static async Task <HttpResponseMessage> Process(HttpContext context)
        {
            // create our response objects
            HttpResponseMessage response = new HttpResponseMessage();

            if (ProcessorUtils.IsOperation(context.Request, out string operationName, out string prevComponent))
            {
                ProcessOperation(ref context, ref response, operationName, prevComponent);
                return(response);
            }

            // get copies of data when we care
            switch (context.Request.Method.ToUpperInvariant())
            {
            case "GET":
                ProcessGet(ref context, ref response);

                break;

            case "PUT":
                response.StatusCode = System.Net.HttpStatusCode.NotImplemented;

                break;

            case "POST":
                ProcessPost(ref context, ref response);

                break;

            case "DELETE":
                // ask the subscription manager to deal with this
                if (SubscriptionManagerR5.HandleDelete(context.Request))
                {
                    response.StatusCode = System.Net.HttpStatusCode.NoContent;
                }
                else
                {
                    response.StatusCode = System.Net.HttpStatusCode.InternalServerError;
                }

                break;

            default:
                // tell client we didn't understand
                response.StatusCode = System.Net.HttpStatusCode.NotImplemented;

                break;
            }

            // return the originator response, plus any modifications we've done
            return(response);
        }