Skip to content

Instantly share code, notes, and snippets.

@fzankl
Last active January 29, 2022 10:19
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 fzankl/d2e81b97d88aaaf3bc8599ff622025af to your computer and use it in GitHub Desktop.
Save fzankl/d2e81b97d88aaaf3bc8599ff622025af to your computer and use it in GitHub Desktop.
Creating a Kestrel server using a Unix socket
const string UnixSocketPath = "/tmp/foo.sock";
if (File.Exists(UnixSocketPath))
{
File.Delete(UnixSocketPath);
}
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options =>
{
options.ListenUnixSocket(UnixSocketPath);
});
var app = builder.Build();
app.MapGet("/", () => "Hello from Foo API served via Unix Socket.");
app.Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment