Created
October 1, 2015 12:54
-
-
Save ota42y/562b4911ac7efc2dfa61 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 ( | |
"fmt" | |
"net/http" | |
) | |
// localhost:8080/ retrun exec folder | |
// localhost:8088/.... return same name file | |
// localhost:8080/handler return url path(from handler function) | |
func handler(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, r.URL.Path[1:]) | |
} | |
func main() { | |
http.HandleFunc("/handler", handler) | |
http.Handle("/", http.FileServer(http.Dir("./"))) | |
http.ListenAndServe(":8080", nil) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment