Skip to content

Instantly share code, notes, and snippets.

@andreadipersio
Last active December 28, 2015 10:38
Show Gist options
  • Save andreadipersio/7487249 to your computer and use it in GitHub Desktop.
Save andreadipersio/7487249 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"log"
"flag"
"net/http"
)
var (
port int
folder string
)
func init() {
flag.IntVar(&port, "port", 8080, "HTTP Server Port")
flag.Parse()
}
func main() {
httpAddr := fmt.Sprintf(":%v", port)
log.Printf("Listening to %v", httpAddr)
// http://golang.org/pkg/net/http/#NotFoundHandler
http.Handle("/cant-touch-this", http.NotFoundHandler())
// http://golang.org/pkg/net/http/#RedirectHandler
http.Handle("/", http.RedirectHandler("http://zombo.com", 302))
log.Fatal(http.ListenAndServe(httpAddr, nil))
}
@RickyS
Copy link

RickyS commented May 14, 2014

So what I'm trying to find is a way to write my own 404 handler, or at least customize the page. Sounds so simple. Not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment