Created
April 3, 2013 20:55
-
-
Save paaschpa/5305198 to your computer and use it in GitHub Desktop.
Trying to use IronPython to run ServiceStack...need to figure out how to register a ServiceStack service.
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
import clr | |
clr.AddReferenceToFile('ServiceStack.dll') | |
clr.AddReferenceToFile('ServiceStack.ServiceInterface.dll') | |
clr.AddReferenceToFile('ServiceStack.Text.dll') | |
clr.AddReferenceToFile('Services.dll') | |
from System import * | |
from ServiceStack.WebHost.Endpoints import AppHostHttpListenerBase | |
from MarkdownSharp import * | |
from ServiceStack.ServiceInterface import * | |
from Services import * | |
from ServiceStack.WebHost.Endpoints import EndpointHost | |
from ServiceStack.ServiceHost import ServiceManager | |
class Hello: | |
def __init__(self): | |
self.Name = "" | |
class HelloService(Service): | |
def Post(self, request): | |
return "Hello" | |
class MyServiceManager(ServiceManager): | |
def __init__(self, *args, **kwargs): | |
return super(MyServiceManager, self).__init__(*args, **kwargs) | |
def GetAssemblyTypes(self, assembliesWithServices): | |
pass #figure out how to manually set routes/register services | |
class AppHost(AppHostHttpListenerBase): | |
def __new__(cls, *args): | |
a = AppHostHttpListenerBase.__new__(cls, "Test IronPython", Type.GetType(cls).Assembly) #will ditch this assembly see override CreateServiceManager | |
return a | |
def CreateServiceManager(self, assembliesWithServices): | |
return MyServiceManager(assembliesWithServices) | |
def Configure(self, container): | |
#self.Routes.Add[str]("/Hello") | |
rt = self.Routes.Add[str]("/Hello") #not doing it | |
print rt.RestPaths[0].RequestType | |
#Routes.Add("/hello") | |
appHost = AppHost() | |
appHost.Init() | |
appHost.Start("http://localhost:1337/") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment