Skip to content

Instantly share code, notes, and snippets.

@mastoj
Created November 12, 2021 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mastoj/830a3adcbca7f0823107e3273d6a4399 to your computer and use it in GitHub Desktop.
Save mastoj/830a3adcbca7f0823107e3273d6a4399 to your computer and use it in GitHub Desktop.
Catch all sample controller
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
namespace catchall.Controllers
{
public record CatchAllResponse(string body, string url);
[ApiController]
[Route("/api")]
public class CatchAllController : ControllerBase
{
[Route("{**catchAll}")]
public async Task<CatchAllResponse> Get(string catchAll)
{
var reader = new StreamReader(Request.Body);
var body = await reader.ReadToEndAsync();
return new CatchAllResponse(body, catchAll);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment