Modular. Flexible. Seamless operation pipelines for .NET.
Spider.Pipelines is a lightweight and flexible .NET library designed to help developers build powerful operation pipelines. It lets you easily attach preprocessors, middlewares, override methods, and postprocessors to your existing logic — just like a spider weaving a smart, modular web. With its clean API and pluggable architecture, you can extend, intercept, or transform operations step by step, making your code more maintainable and testable.
-
- 🕷️ Modular: build pipelines with preprocessors, middlewares, overrides, and postprocessors
- ⚡ Fast: delegate-based and optimized for performance
- 🔌 DI-friendly: plug seamlessly into any
IServiceProvider - 🧩 Composable: chain and nest pipeline steps with full control
- 🧼 Zero dependencies (except for DI abstractions)
- 🧪 Battle-tested with xUnit & NSubstitute
- 🛠️ Extensible: create custom steps, handlers, and behaviors
- 🧠 Introspectable: pipeline metadata available at runtime
- 🧵 Thread-safe: pipelines are designed for concurrent execution
dotnet add package Spider.Pipelinesservices.AddSpider();public class MyService
{
public Task<string> Handle(string input, CancellationToken token)
{
// Your business logic here
return Task.FromResult($"Hello, {input}!");
}
}var spider = provider.GetRequiredService<ISpider>();
var bridge = spider.InitBridge<MyService>();
bridge.Attach<string, string>(builder =>
{
builder.OnPreProcess(cfg =>
{
cfg.OnPreProcess((ctx, args) =>
{
Console.WriteLine($"Preprocessing: {ctx.Request}");
return Task.CompletedTask;
});
});
builder.OnTargeting(cfg =>
{
cfg.Overrides((req, token) => Task.FromResult($"Targeted: {req}"));
});
builder.OnPostProcess(cfg =>
{
cfg.OnSuccess((ctx, args) =>
{
Console.WriteLine($"Success: {ctx.Response}");
return Task.CompletedTask;
});
});
});var result = await bridge.ExecuteAsync(
svc => (input, token) => svc.Handle(input, token),
"World"
);
Console.WriteLine(result); // Output: Hello, World!- Add middlewares Adding middleware execution.