Skip to content

Instantly share code, notes, and snippets.

@ota42y
Created October 1, 2015 12:54
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 ota42y/562b4911ac7efc2dfa61 to your computer and use it in GitHub Desktop.
Save ota42y/562b4911ac7efc2dfa61 to your computer and use it in GitHub Desktop.
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