Created
May 29, 2014 11:24
-
-
Save scottmcarthur/c07f77cfcaa3ba5edd61 to your computer and use it in GitHub Desktop.
ServiceStack HttpError.NotFound bug when using DELETE method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Funq; | |
using ServiceStack; | |
namespace V4 | |
{ | |
class MainClass | |
{ | |
public static void Main() | |
{ | |
// Simple Self-Hosted Console App | |
var appHost = new AppHost(500); | |
appHost.Init(); | |
appHost.Start("http://*:9000/"); | |
Console.ReadKey(); | |
} | |
} | |
public class AppHost : AppHostHttpListenerPoolBase | |
{ | |
public AppHost(int poolSize) : base("Test Service", poolSize, typeof(TestService).Assembly) | |
{ | |
} | |
public override void Configure(Container container) | |
{ | |
SetConfig(new HostConfig { | |
DebugMode = true | |
}); | |
} | |
} | |
[Route("/Test1", "DELETE")] | |
public class Test1Request {} | |
[Route("/Test2", "DELETE")] | |
public class Test2Request {} | |
[Route("/Test3", "DELETE")] | |
public class Test3Request {} | |
public class TestService : Service | |
{ | |
public string Delete(Test1Request request) | |
{ | |
// Works as expected | |
return "hello"; | |
} | |
public string Delete(Test2Request request) | |
{ | |
// Shows a handler not found error instead of custom 404?? | |
throw HttpError.NotFound("No such record"); | |
return "hello"; | |
} | |
public string Delete(Test3Request request) | |
{ | |
// Works as expected | |
throw HttpError.Unauthorized("Unauthorized"); | |
return "hello"; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment