Skip to content

Instantly share code, notes, and snippets.

Created March 9, 2023 01:05
What would you like to do?
A Simple Go HTTP Server
package main
import (
func hello(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "hello\n")
func headers(w http.ResponseWriter, req *http.Request) {
for name, headers := range req.Header {
for _, h := range headers {
fmt.Fprintf(w, "%v: %v\n", name, h)
func main() {
http.HandleFunc("/hello", hello)
http.HandleFunc("/headers", headers)
http.ListenAndServe(":8090", nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment