Skip to content

Instantly share code, notes, and snippets.

View stormwild's full-sized avatar
🏠
Working from home

Alexander R Torrijos stormwild

🏠
Working from home
View GitHub Profile
@stormwild
stormwild / 1-Program.cs
Created October 1, 2024 09:00 — forked from dj-nitehawk/1-Program.cs
Response sending post-processor with ErrorOr package
var bld = WebApplication.CreateBuilder(args);
bld.Services
.SwaggerDocument()
.AddFastEndpoints();
var app = bld.Build();
app.UseFastEndpoints(
c =>
{
c.Errors.UseProblemDetails();
@stormwild
stormwild / Program.cs
Created October 1, 2024 09:00 — forked from dj-nitehawk/Program.cs
Results pattern with a Post-Processor doing the response sending.
var bld = WebApplication.CreateBuilder(args);
bld.Services
.AddFastEndpoints()
.SwaggerDocument();
var app = bld.Build();
app.UseFastEndpoints()
.UseSwaggerGen();
app.Run();
@stormwild
stormwild / program.cs
Created October 1, 2024 09:00 — forked from dj-nitehawk/program.cs
FastEndpoints usage with Ardalis.Result package
using Ardalis.Result;
using FastEndpoints;
using FastEndpoints.Swagger;
var bld = WebApplication.CreateBuilder();
bld.Services
.AddFastEndpoints()
.SwaggerDocument();
var app = bld.Build();

Read Part 1: MediatR vs MassTransit Mediator - Differences

The MassTransit Mediator implementation is more powerful than MediatR implementation, but also more complicate to use. Unit Testing a MassTransit Consumer is not a nice experience.

In this article I will propose some techniques to simplify the MassTransit Consumer and to make them look as straight forward as a MediatR handler.

Case study

We will study a very common use case (the most common use case which I can think of):

Why mediator?

In a ASP.NET Web application. You don't need mediator

  • If you prefers to make controlers depends directly to the Application Codes instead of indirectly via the Mediator.
  • If you prefers to make a normal ASP.NET Web Application instead of a Mediator Application

Frankly it is not a Bad choice, no need to use a Mediator framework or make a Mediator Application just because everyone did.. Though, There are benefits in making a Mediator Application:

  • Event sourcing (Messages broadcast), CQS pattern..
  • Decouple the Controler (presentation) from Application codes, so that you could swap the presentation technology. For eg, if you make a "MassTransit" application, then you can swap the presentation layer to Mediator or RabbitMQ, or Grpc.. => you are not to be sticked with or limited by ASP.NET presentation => but rather sticked with and limited by your mediator framework!
@stormwild
stormwild / test.md
Created July 29, 2023 16:06 — forked from ityonemo/test.md
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

@stormwild
stormwild / git bash ssh agent.md
Created May 19, 2023 11:01 — forked from Peregrinox/git bash ssh agent.md
configure your git bash to run agent on start
@stormwild
stormwild / 0 - ServiceHost.cs
Created July 2, 2021 08:35 — forked from andriybuday/0 - ServiceHost.cs
Microsoft.Extensions.DependencyInjection with OWIN Self-Hosted WebAPI
// ...
using Microsoft.Owin.Hosting;
// ...
public class ServiceHost
{
private IDisposable server = null;
const string baseAddress = "https://*:443";
public void Start()