Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            IResourceResponse resourceResponse;
            var resourceRequestContext = new ResourceRequestContext(context, _requestContext.RouteData.Values);
            var requestVerb = context.Request.HttpMethod;

            if (requestVerb == VERB_GET)
            {
                resourceResponse = _resource.Get(resourceRequestContext);
            }
            else if (requestVerb == VERB_POST)
            {
                resourceResponse = _resource.Post(resourceRequestContext);
            }
            else if (requestVerb == VERB_PUT)
            {
                resourceResponse = _resource.Put(resourceRequestContext);
            }
            else if (requestVerb == VERB_DELETE)
            {
                resourceResponse = _resource.Delete(resourceRequestContext);
            }
            else
            {
                throw new InvalidOperationException(
                    String.Format("Unknown verb {0}", requestVerb));
            }

            if (resourceResponse == null)
            {
                throw new InvalidOperationException(
                    String.Format(
                        "Resource type '{0}' returned a null response for the verb '{1}'",
                        _resource.GetType().FullName,
                        requestVerb));
            }

            resourceResponse.Execute(context.Response);
        }
Esempio n. 2
0
 public override IResourceResponse Get(ResourceRequestContext context)
 {
     return new TemplateResponse("~/index.haml");
 }
Esempio n. 3
0
 public virtual IResourceResponse Put(ResourceRequestContext context)
 {
     throw new InvalidOperationException("This view does not support the verb 'PUT'");
 }