Skip to main content
100%

golang web examples

✓ Published0🌍 Public
Aankuagar
Last edited Sep 23, 2014
Created on Apr 27, 2022

This example demonstrates basic HTTP server patterns in Go, showing how to build routes with public and private endpoints. It uses the standard `net/http` package to define handlers for the root, `/post`, and `/json` routes, with middleware wrappers like `BasicAuth`, `GetOnly`, and `PostOnly` controlling access. The code includes functions for basic authentication, request method filtering, and JSON responses via `encoding/json`. A shell script runs `curl` commands to test the server’s behavior.

AI-generated description

A few examples to peruse after reading Peter Bourgon's awesome tutorial, which walks you through the building of a backend service for a web app.

See also

Similar vizzes