예제 #1
0
        public NancyServiceModule(IEnumerable <ServiceInfo> services)
        {
            Options[@"^(.*)$"] = p => CORS.Handle_preflight_request(Request);

            foreach (var service in services)
            {
                Register_service(service);
            }
        }
예제 #2
0
        Func <dynamic, dynamic> Create_handler(ServiceInfo service)
        {
            return((dynamic param) => {
                try {
                    var input = Get_input(param, service);

                    var handler = new ServiceAdapter(service.ServiceType, service.EntryPointMethodname, service.SetupMethodname, service.TeardownMethodname);
                    var output = handler.Execute(input);

                    var response = Produce_output(output);
                    return CORS.Handle_simple_request(Request, response);
                }
                catch (Exception ex) {
                    var resp = (Response)($"ServiceHost: Service request could not be handled! Exception: {ex}");
                    resp.StatusCode = HttpStatusCode.InternalServerError;
                    return resp;
                }
            });
        }