Skip to content

Commit 5290d8d

Browse files
committed
couple bug fixes, performance tweaks and wiki documentation
1 parent 5b0e816 commit 5290d8d

File tree

12 files changed

+1765
-10
lines changed

12 files changed

+1765
-10
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Each request flows through a simple, predictable pipeline:
5151
4. 🏁 **After Handle** - Invokes `AfterHandleAsync()` for logging or cleanup
5252
5. 🛡️ **Exception Handling** - Any exceptions are caught and returned as `Result.Failure` with the exception attached
5353

54+
📚 **[Read the full documentation on the Wiki →](https://github.com/AlanBarber/ResultR/wiki)**
55+
5456
## 📥 Installation
5557

5658
```bash
@@ -203,21 +205,27 @@ var result = Result<User>.Success(user)
203205
.WithMetadata("Source", "API");
204206
```
205207

206-
### Validation Only
208+
### Optional Hooks
209+
210+
Override only the hooks you need - no base class required:
207211

208212
```csharp
209-
// Handlers can override validation without other hooks
210-
public class ValidatingHandler : IRequestHandler<MyRequest, MyResponse>
213+
// Just validation + handle (no before/after hooks)
214+
public class ValidatingHandler : IRequestHandler<CreateOrderRequest, Order>
211215
{
212-
public ValueTask<Result> ValidateAsync(MyRequest request)
216+
public ValueTask<Result> ValidateAsync(CreateOrderRequest request)
213217
{
214-
// Validation logic
218+
if (request.Items.Count == 0)
219+
return new(Result.Failure("Order must have at least one item"));
220+
215221
return new(Result.Success());
216222
}
217223

218-
public async ValueTask<Result<MyResponse>> HandleAsync(MyRequest request, CancellationToken cancellationToken)
224+
public async ValueTask<Result<Order>> HandleAsync(CreateOrderRequest request, CancellationToken cancellationToken)
219225
{
220-
// Handle logic
226+
// This only runs if validation passes
227+
var order = await _repository.CreateAsync(request, cancellationToken);
228+
return Result<Order>.Success(order);
221229
}
222230
}
223231
```

0 commit comments

Comments
 (0)