public void ConfigureServer(IRestServer server) { server.Prefixes.Add($"http://localhost:{_serverPort}/"); /* Configure Router Options (if supported by your router implementation) */ server.Router.Options.SendExceptionMessages = true; }
/// <summary> /// Applies the global headers to the provided response header collection. /// </summary> /// <param name="server"></param> /// <param name="headers"></param> public static void ApplyGlobalResponseHeaders(this IRestServer server, WebHeaderCollection headers) { foreach (var header in server.GlobalResponseHeaders.Where(g => !g.Suppress)) { headers.Add(header.Name, header.Value); } }
internal HttpContext(HttpListenerContext context, IRestServer server) { Request = new HttpRequest(context.Request); Response = new HttpResponse(context.Response, context.Request.Headers); User = context.User; Server = server; }
/// <summary> /// Starts the server and blocks the calling thread until the server stops listening /// </summary> public static void Run(this IRestServer server) { server.Start(); while (server.IsListening) { } }
public static void Start() { if (restServer != null && restServer.IsListening) { return; } try { restServer = RestServerBuilder.From <Startup>().Build(); //restServer = RestServerBuilder.UseDefaults().Build(); //Urls = restServer.Prefixes.ToList(); restServer.AfterStarting += (s) => { Process.Start("explorer", s.Prefixes.First()); }; restServer.AfterStopping += (s) => { Console.WriteLine("Web-Server beendet."); }; //Urls = restServer.Prefixes.ToList(); restServer.Start(); } catch (Exception ex) { throw ex; } }
public static IRestServer UseCorrelationId(this IRestServer server, string correlationIdFieldName, Func <string> correlactionIdGenerator) { var mw = new CorrelationId(correlationIdFieldName, correlactionIdGenerator); server.OnRequestAsync += mw.EnsureCorrelationIdAsync; return(server); }
public void CloneEventHandlers(IRestServer server) { if (BeforeStarting != null) { foreach (var action in BeforeStarting.GetInvocationList().Reverse().Cast <ServerEventHandler>()) { server.BeforeStarting += action; } } if (AfterStarting != null) { foreach (var action in AfterStarting.GetInvocationList().Reverse().Cast <ServerEventHandler>()) { server.AfterStarting += action; } } if (BeforeStopping != null) { foreach (var action in BeforeStopping.GetInvocationList().Reverse().Cast <ServerEventHandler>()) { server.BeforeStopping += action; } } if (AfterStopping != null) { foreach (var action in AfterStopping.GetInvocationList().Reverse().Cast <ServerEventHandler>()) { server.AfterStopping += action; } } }
/// <summary> /// Adds a server to the cluster /// </summary> public void Add(string label, IRestServer server) { if (_started) { server.Start(); } _servers.Add(label, server); }
/// <summary> /// Adds a server to the cluster /// </summary> public void Add(string label, IRestServer server) { Servers.Add(label, server); if (Started) { OnBeforeStartEach?.Invoke(server); server.Start(); OnAfterStartEach?.Invoke(server); } }
protected override void OnStartup(object sender, StartupEventArgs e) { MainKernel.Load<MainModule>(); MainKernel.Load<QueueItemModule>(); MainKernel.Load<ClientModule>(); _restServer = MainKernel.Get<IRestServer>(); _restServer.Start(); DisplayRootViewFor<IMainViewModel>(); }
public void ConfigureServer(IRestServer server) { // The path to your static content var folderPath = Path.Combine(Directory.GetCurrentDirectory(), "website"); // The following line is shorthand for: // server.ContentFolders.Add(new ContentFolder(folderPath)); server.ContentFolders.Add(folderPath); server.UseContentFolders(); server.Prefixes.Add($"http://localhost:{_serverPort}/"); /* Configure Router Options (if supported by your router implementation) */ server.Router.Options.SendExceptionMessages = true; }
public MainApplication(IConfigurationService configurationService, IRecordService recordService, IPlaybackService playbackService, IRestServer restServer, IRestRouter[] routers, IStreamingServer streamingServer, IQueryService[] queryServices) { _startMode = configurationService.GetConfiguration().StartMode; _recordService = recordService; _playbackService = playbackService; _streamingServer = streamingServer; _restServer = restServer; _restRouters = routers; _queryServices = queryServices; _currentMode = ApplicationMode.Waiting; }
internal HttpContext(HttpListenerContext context, IRestServer server, CancellationToken token) { Advanced = context; Server = server; CancellationToken = token; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding var acceptEncoding = context.Request.Headers.GetValue <string>("Accept-Encoding", string.Empty); var identityForbidden = (acceptEncoding.Contains("identity;q=0") || acceptEncoding.Contains("*;q=0")); Request = new HttpRequest(context.Request); Response = new HttpResponse(context.Response) { CompressionProvider = new CompressionProvider(QualityValues.Parse(acceptEncoding), identityForbidden), ContentExpiresDuration = server.Router.Options.ContentExpiresDuration }; server.ApplyGlobalResponseHeaders(Response.Headers); }
public static IRestServer UseContentFolders(this IRestServer server) { server.OnRequestAsync += ContentFolders.SendFileIfExistsAsnyc; return(server); }
public static IRestServer UseCorsPolicy(this IRestServer server, ICorsPolicy policy) { server.OnRequestAsync += policy.ApplyAsync; return(server); }
public static IRestServer UseCorsPolicy(this IRestServer server, IEnumerable <Uri> allowOrigins) { return(server.UseCorsPolicy(new CorsPolicy(allowOrigins))); }
public static IRestServer UseCorsPolicy(this IRestServer server, IEnumerable <string> allowOrigins) { return(server.UseCorsPolicy(allowOrigins.Cast <Uri>().ToList())); }
public static IRestServer UseCorsPolicy(this IRestServer server, Uri allowOrigin) { return(server.UseCorsPolicy(new CorsPolicy(allowOrigin))); }
public static IRestServer UseCorsPolicy(this IRestServer server) { server.OnRequestAsync += CorsPolicy.CorsWildcardAsync; return(server); }
public static IRestServer SetDefaultLogger(this IRestServer server, ILoggerFactory factory) { LoggerFactory = factory; return(server); }
/// <summary> /// Adds a server to the cluster /// </summary> /// <param name="server"></param> /// <returns>Assigned labled of the server that was addded</returns> public string Add(IRestServer server) { Add(server.ListenerPrefix, server); return(server.ListenerPrefix); }
public void RunInteractiveShell(IRestServer server) { _server = server; InteractiveShell.Start(); }
public static IRestServer UseCorrelationId(this IRestServer server, string correlationIdFieldName) { return(server.UseCorrelationId(correlationIdFieldName, null)); }
/// <summary> /// For use in routes that want to stop the server; starts a new thread and then calls Stop on the server /// </summary> public static void ThreadSafeStop(this IRestServer server) { new Thread(server.Stop).Start(); }
public static IRestServer UseCorrelationId(this IRestServer server, Func <string> correlactionIdGenerator) { return(server.UseCorrelationId(null, correlactionIdGenerator)); }