the simplest REST-ful .NET app
2008-09-23 @ 18:36#
ok, i gotta ask. when you start building a REST-ful application using C# and .NET *why* do you need anything more than the code below to start?
using System;
using System.Web;
using System.Net;
public class ResourceName: IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
switch(context.Request.HttpMethod.ToLower())
{
case "head":
case "get":
Get(context);
break;
case "post":
Post(context);
break;
case "put":
Put(context);
break;
case "delete":
Delete(context);
break;
case "option":
Option(context);
break;
default:
throw new HttpException(HttpStatusCode.MethodNotAllowed, "Unsupported Method");
break;
}
}
public bool IsReusable
{
get
{
return false;
}
}
}