Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created October 22, 2025 15:22
Show Gist options
  • Select an option

  • Save dcomartin/7a8adc8ab5972e05a46676bf9794b8b2 to your computer and use it in GitHub Desktop.

Select an option

Save dcomartin/7a8adc8ab5972e05a46676bf9794b8b2 to your computer and use it in GitHub Desktop.
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddAuthorization(options =>
{
options.AddPolicy("DispatchManagerOnly", policy =>
policy.RequireRole("DispatchManager"));
});
var app = builder.Build();
app.UseHttpsRedirection();
app.MapPost("/shipments/assign", () => "Assign shipments to dispatchers logic is here...")
.RequireAuthorization("DispatchManagerOnly");
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment