// Define the ZipFileSchemaMessageHandler class that is derived from the CustomSchemaMessageHandler class class ZipFileSchemaMessageHandler : CustomSchemaMessageHandler { private readonly Archive archive; public ZipFileSchemaMessageHandler(Archive archive) : base("zip-file") { this.archive = archive; } // Override the Invoke() method public override void Invoke(INetworkOperationContext context) { var pathInsideArchive = context.Request.RequestUri.Pathname.TrimStart('/').Replace("\\", "/"); var stream = GetFile(pathInsideArchive); if (stream != null) { // If a resource is found in the archive, then return it as a Response var response = new ResponseMessage(HttpStatusCode.OK); response.Content = new StreamContent(stream); response.Headers.ContentType.MediaType = MimeType.FromFileExtension(context.Request.RequestUri.Pathname); context.Response = response; } else { context.Response = new ResponseMessage(HttpStatusCode.NotFound); } // Invoke the next message handler in the chain Next(context); } Stream GetFile(string path) { var result = archive .Entries .FirstOrDefault(x => x.Name == path); return result?.Open(); } }