Created
December 10, 2019 05:32
-
-
Save Mukundan314/ecb9b328aad8a66e22bda6496651b0ff to your computer and use it in GitHub Desktop.
This file contains 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 ( | |
"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