Skip to content

Instantly share code, notes, and snippets.

@Mahmud139
Mahmud139 / 00_README.md
Created September 9, 2022 08:40 — forked from reagent/00_README.md
Custom HTTP Routing in Go

Custom HTTP Routing in Go

Basic Routing

Responding to requests via simple route matching is built in to Go's net/http standard library package. Just register the path prefixes and callbacks you want invoked and then call the ListenAndServe to have the default request handler invoked on each request. For example:

package main

import (