basic-http-server

command
v0.74.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

README

Basic HTTP Server

This example is a minimal HTTP server built with dioad/net/http.

Running the Example

go run github.com/dioad/net/examples/basic-http-server

Or build and run:

cd examples/basic-http-server
go build
./basic-http-server

Then test with:

curl http://localhost:8080/hello

Stop it with Ctrl+C or SIGTERM. It exits with status 0 after a clean shutdown.

What It Demonstrates

  • Creating a server and adding a route
  • A *http.Server run by lifecycle.App: no adapter, and a bind failure is an error from Run
  • Graceful shutdown on SIGINT or SIGTERM, and an unexpected end of the serve loop ending the process
  • Structured logging with zerolog: a service field, and zerolog.Ctx in the handler

Code

See main.go for the complete executable example.

Documentation

Overview

Package main demonstrates a minimal HTTP server built with dioad/net/http.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL