Last active
December 28, 2015 10:38
-
-
Save andreadipersio/7487249 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.