Created
November 12, 2021 08:45
-
-
Save mastoj/830a3adcbca7f0823107e3273d6a4399 to your computer and use it in GitHub Desktop.
Catch all sample controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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