Inspection

Live on this server

Shows what the server received and responded, to debug clients.

Shows what the server received and what it answered, to find out why a client gets a certain response. Add ?inspect to an address below the layout, and instead of the response you get the request as GenHTTP read it - method, path, query and headers - together with the response it would have sent.

Add the inspector while developing only, as it reveals details of your server.

To run it, create a console app (dotnet new console), add GenHTTP (dotnet add package GenHTTP.Full), replace Program.cs with the code below and start it with dotnet run - it answers at http://localhost:8080/.

Program.cs20 lines
using GenHTTP.Engine.Internal;

using GenHTTP.Modules.Functional;
using GenHTTP.Modules.Inspection;
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.Practices;

var orders = Inline.Create()
                   .Get((int limit) => Enumerable.Range(1, limit).Select(i => new Order(i)));

var app = Layout.Create()
                .Add("api/orders", orders) // GET /api/orders/?limit=5&inspect
                .AddInspector(); // only while developing, as it reveals details of your server

await Host.Create()
          .Handler(app)
          .Defaults()
          .RunAsync();

public record Order(int Id);

Try it

Send the requests to the sample running on this server - change the path, headers or body as you like, or copy them as curl commands.

  1. Call the API

    GET
    curl -i 'https://genhttp.org/demo/inspection/api/orders/?limit=5'
  2. Inspect the call

    GET
    curl -i 'https://genhttp.org/demo/inspection/api/orders/?limit=5&inspect'