A set of simple HTTP services written using the standard library in go
install the go compiler
go run cmd/simple1/main.go
go run cmd/simple2/main.go
go run cmd/simple3/main.go
Pretty dead simple handler and server setup. Just return a string if the request method is GET
Introduce some additional handlers and handle some JSON input and output
- Use multiplexing to route handlers
- Wrap handlers in some middleware functions
- Use context to pass a request scoped requestID through the handler cycle
- Try to gracefully handle server timeouts and interrupts / cancellations using channels
- Use HTTPS
Create the key file for serving with TLS
openssl req -new -newkey rsa:2048 -nodes -keyout localhost.key -out localhost.csr
openssl x509 -req -days 365 -in localhost.csr -signkey localhost.key -out localhost.crt