public RestMiddleware( IPluginRepository <IServerCommand> commandsRepository, RestApplication application) { this.CommandsRepository = commandsRepository; this.Application = application; }
public RestController( IPluginRepository <IServerCommand> commandsRepository, RestApplication application) { this.CommandsRepository = commandsRepository; this.Application = application; }
public CommandConverter( RestApplication application, IObjectFactory objectFactory, IProcessingEngine processingEngine, IWireSerialization serialization) { this.Application = application; this.ObjectFactory = objectFactory; this.ProcessingEngine = processingEngine; this.Serialization = serialization; }
public void PassThrough <TCommand, TArgument>( TArgument argument, string accept, HttpContext contex, AdditionalCommand[] additionalCommands) { var request = contex.Request; var response = contex.Response; var start = Stopwatch.GetTimestamp(); var engine = ProcessingEngine; StringValues headers; if (request.Headers.TryGetValue("x-revenj-session-id", out headers) && headers.Count == 1) { var sessionID = headers[0]; var scope = ObjectFactory.FindScope(sessionID); if (scope == null) { response.WriteError("Unknown session: " + sessionID, HttpStatusCode.BadRequest); return; } engine = scope.Resolve <IProcessingEngine>(); } var commands = new ObjectCommandDescription[1 + (additionalCommands != null ? additionalCommands.Length : 0)]; commands[0] = new ObjectCommandDescription { Data = argument, CommandType = typeof(TCommand) }; for (int i = 1; i < commands.Length; i++) { var ac = additionalCommands[i - 1]; commands[i] = new ObjectCommandDescription { RequestID = ac.ToHeader, CommandType = ac.CommandType, Data = ac.Argument }; } var stream = RestApplication.ExecuteCommands <object>(engine, Serialization, commands, contex, accept); var elapsed = (decimal)(Stopwatch.GetTimestamp() - start) / TimeSpan.TicksPerMillisecond; response.Headers.Add("X-Duration", elapsed.ToString(CultureInfo.InvariantCulture)); var cms = stream as ChunkedMemoryStream; if (cms != null) { cms.CopyTo(response.Body); } else if (stream != null) { stream.CopyTo(response.Body); } }