using System.Text; var builder = WebApplication.CreateBuilder(args); var app = builder.Build(); app.MapGet("/", () => { var id = 123; var entity = "posts"; var page = 2; var f = ""; var sb = new StringBuilder(); sb.AppendLine("** Value Objects **"); sb.AppendLine(PathGenerator.GetPath("/user/{id}/{entity}", new { id, entity, page, f, q = "test with spaces" })); sb.AppendLine(PathGenerator.GetPath("/user/{id}/{entity}/", new { id, entity, page, f, q = "test with spaces" })); sb.AppendLine(PathGenerator.GetPath("user/{id}/{entity}", new { id, entity, page })); sb.AppendLine(PathGenerator.GetPath("user/{id}/{entity}", new { id, entity = "entity with spaces", page })); sb.AppendLine(PathGenerator.GetPath("/user/{id}/{entity?}", new { id, page })); sb.AppendLine(PathGenerator.GetPath("/user/{id}/{entity?}", new { id, entity, page })); sb.AppendLine(); sb.AppendLine("** Ordinal **"); sb.AppendLine(PathGenerator.GetPath("/user/{0}/{1}?page={2}", id, entity, page)); sb.AppendLine(PathGenerator.GetPath("/user/{0}/{1}?page={2}&q={3}", id, entity, page, "test with spaces")); sb.AppendLine(); sb.AppendLine("** Interpolated **"); sb.AppendLine(PathGenerator.GetPath($"/user/{id}/{entity}?page={page}")); sb.AppendLine(PathGenerator.GetPath($"/user/{id}/{entity}?page={47}&f={f}&q={"test with spaces"}")); return Results.Text(sb.ToString(), "text/plain", Encoding.UTF8); }); app.Run();