Skip to content

Instantly share code, notes, and snippets.

@Mukundan314
Created December 10, 2019 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mukundan314/ecb9b328aad8a66e22bda6496651b0ff to your computer and use it in GitHub Desktop.
Save Mukundan314/ecb9b328aad8a66e22bda6496651b0ff to your computer and use it in GitHub Desktop.
package main
import (
"net/http"
"log"
)
var urlMap = map[string]string{
"google": "https://google.com",
"github": "https://github.com",
"gci": "https://codein.withgoogle.com",
}
func handler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, urlMap[r.URL.Path[1:]], 301)
}
func main() {
http.HandleFunc("/", handler)
log.Fatal(http.ListenAndServe(":8080", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment