public void SetUp() { _router = _uriRouterFactory(); _router.RegisterAction(new ControllerAction("/", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/{placeholder}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/halt", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/streams/{stream}/{event}/backward/{count}?embed={embed}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/projection/{name}?deleteStateStream={deleteStateStream}&deleteCheckpointStream={deleteCheckpointStream}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/s/stats/{*statPath}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/streams/$all/", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/streams/$$all", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/streams/$mono?param={param}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/streams/test", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/streams/test", HttpMethod.Post, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/{placholder2}/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/{placholder2}/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/something/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/something/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/something/{placholder2}/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/something/{placholder2}/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/something/something/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); _router.RegisterAction(new ControllerAction("/t/something/something/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => { }); }
public void SetUp() { _router = _uriRouterFactory(); var p = new RequestParams(TimeSpan.Zero); _router.RegisterAction(new ControllerAction("/", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/{placeholder}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/halt", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/streams/{stream}/{event}/backward/{count}?embed={embed}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/projection/{name}?deleteStateStream={deleteStateStream}&deleteCheckpointStream={deleteCheckpointStream}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/s/stats/{*statPath}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/streams/$all/", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/streams/$$all", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/streams/$mono?param={param}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/streams/test", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/streams/test", HttpMethod.Post, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/{placholder2}/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/{placholder2}/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/something/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/{placeholder1}/something/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/something/{placholder2}/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/something/{placholder2}/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/something/something/{placeholder3}", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); _router.RegisterAction(new ControllerAction("/t/something/something/something", HttpMethod.Get, Codec.NoCodecs, FakeController.SupportedCodecs), (x, y) => p); }
public KestrelToInternalBridgeMiddleware(IUriRouter uriRouter, bool logHttpRequests, IPAddress advertiseAsAddress, int advertiseAsPort) { _uriRouter = uriRouter; _logHttpRequests = logHttpRequests; _advertiseAsAddress = advertiseAsAddress; _advertiseAsPort = advertiseAsPort; }
public HttpService(ServiceAccessibility accessibility, IPublisher inputBus, IUriRouter uriRouter, MultiQueuedHandler multiQueuedHandler, params string[] prefixes) { Ensure.NotNull(inputBus, "inputBus"); Ensure.NotNull(uriRouter, "uriRouter"); Ensure.NotNull(prefixes, "prefixes"); _accessibility = accessibility; _inputBus = inputBus; _uriRouter = uriRouter; _publishEnvelope = new PublishEnvelope(inputBus); _requestsMultiHandler = multiQueuedHandler; _server = new HttpAsyncServer(prefixes); _server.RequestReceived += RequestReceived; }
public KestrelHttpService(ServiceAccessibility accessibility, IPublisher inputBus, IUriRouter uriRouter, MultiQueuedHandler multiQueuedHandler, bool logHttpRequests, IPAddress advertiseAsAddress, int advertiseAsPort, bool disableAuthorization, params IPEndPoint[] endPoints) { Ensure.NotNull(inputBus, nameof(inputBus)); Ensure.NotNull(uriRouter, nameof(uriRouter)); Ensure.NotNull(endPoints, nameof(endPoints)); _accessibility = accessibility; _inputBus = inputBus; UriRouter = uriRouter; LogHttpRequests = logHttpRequests; AdvertiseAsAddress = advertiseAsAddress; AdvertiseAsPort = advertiseAsPort; EndPoints = endPoints; }
public HttpService(ServiceAccessibility accessibility, IPublisher inputBus, IUriRouter uriRouter, MultiQueuedHandler multiQueuedHandler, bool logHttpRequests, IPAddress advertiseAsAddress, int advertiseAsPort, params string[] prefixes) { Ensure.NotNull(inputBus, "inputBus"); Ensure.NotNull(uriRouter, "uriRouter"); Ensure.NotNull(prefixes, "prefixes"); _accessibility = accessibility; _inputBus = inputBus; _uriRouter = uriRouter; _publishEnvelope = new PublishEnvelope(inputBus); _requestsMultiHandler = multiQueuedHandler; _logHttpRequests = logHttpRequests; _server = new HttpAsyncServer(prefixes); _server.RequestReceived += RequestReceived; _advertiseAsAddress = advertiseAsAddress; _advertiseAsPort = advertiseAsPort; }
public FakeController(int reqCount, IUriRouter router) { _router = router; CountdownEvent = new CountdownEvent(reqCount); }
public FakeController(int reqCount, IUriRouter router) { _router = router; CountdownEvent = new CountdownEvent(reqCount); }
private static bool TryMatch(HttpContext context, IUriRouter uriRouter, bool logHttpRequests, IPAddress advertiseAsAddress, int advertiseAsPort) { var tcs = new TaskCompletionSource <bool>(); var httpEntity = new HttpEntity(context, logHttpRequests, advertiseAsAddress, advertiseAsPort, () => tcs.TrySetResult(true)); var request = httpEntity.Request; try { var allMatches = uriRouter.GetAllUriMatches(request.Url); if (allMatches.Count == 0) { NotFound(httpEntity); return(false); } var allowedMethods = GetAllowedMethods(allMatches); if (request.HttpMethod.Equals(HttpMethod.Options, StringComparison.OrdinalIgnoreCase)) { RespondWithOptions(httpEntity, allowedMethods); return(false); } var match = allMatches.LastOrDefault( m => m.ControllerAction.HttpMethod.Equals(request.HttpMethod, StringComparison.OrdinalIgnoreCase)); if (match == null) { MethodNotAllowed(httpEntity, allowedMethods); return(false); } ICodec requestCodec = null; var supportedRequestCodecs = match.ControllerAction.SupportedRequestCodecs; if (supportedRequestCodecs != null && supportedRequestCodecs.Length > 0) { requestCodec = SelectRequestCodec(request.HttpMethod, request.ContentType, supportedRequestCodecs); if (requestCodec == null) { BadContentType(httpEntity, "Invalid or missing Content-Type"); return(false); } } ICodec responseCodec = SelectResponseCodec(request, request.AcceptTypes, match.ControllerAction.SupportedResponseCodecs, match.ControllerAction.DefaultResponseCodec); if (responseCodec == null) { BadCodec(httpEntity, "Requested URI is not available in requested format"); return(false); } try { var manager = httpEntity.CreateManager(requestCodec, responseCodec, allowedMethods, satisfied => { }); context.Items.Add(manager.GetType(), manager); context.Items.Add(match.GetType(), match); context.Items.Add(tcs.GetType(), tcs); return(true); } catch (Exception exc) { Log.Error(exc, "Error while handling HTTP request '{url}'.", request.Url); InternalServerError(httpEntity); } } catch (Exception exc) { Log.Error(exc, "Unhandled exception while processing HTTP request at {url}.", httpEntity.RequestedUrl); InternalServerError(httpEntity); } return(false); }