Skip to content

Instantly share code, notes, and snippets.

@paaschpa
Created April 17, 2013 15:02
Show Gist options
  • Save paaschpa/5405028 to your computer and use it in GitHub Desktop.
Save paaschpa/5405028 to your computer and use it in GitHub Desktop.
Test Console App for this SO question - http://stackoverflow.com/questions/16057527/servicestack-hitting-the-wrong-http-verb. Tested using Fiddler to make requests.
class Program
{
static void Main(string[] args)
{
var appHost = new AppHost();
appHost.Init();
appHost.Start("http://*:1337/");
System.Console.WriteLine("Listening on http://localhost:1337/ ...");
System.Console.ReadLine();
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
}
}
public class AppHost : AppHostHttpListenerBase
{
public AppHost() : base("Test Console", typeof(AppHost).Assembly) { }
public override void Configure(Funq.Container container)
{
Plugins.Add(new RegisterRoutes());
}
}
public class SourceInfo
{
public string Name { get; set; }
}
public class SourceInfoResponse
{
}
public class SourceService : ServiceStack.ServiceInterface.Service
{
public SourceInfoResponse Get(SourceInfo sourceInfo)
{
return new SourceInfoResponse();
}
public bool Post(SourceInfo source)
{
return true;
}
public bool Put(SourceInfo source)
{
return true;
}
public bool Delete(SourceInfo source)
{
return true;
}
}
public class RegisterRoutes : IPlugin
{
public void Register(IAppHost appHost)
{
appHost.Routes.Add<SourceInfo>("/sources", "GET,POST,PUT");
appHost.Routes.Add<SourceInfo>("/sources/{Name}", "GET,DELETE");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment