Last active
April 5, 2019 00:08
-
-
Save petitviolet/bff05fd9c51b5059a36310e0477c4be1 to your computer and use it in GitHub Desktop.
static file server written in golang.
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 ( | |
"log" | |
"net/http" | |
) | |
func main() { | |
log.Println("Server started. 0.0.0.0:8080") | |
http.ListenAndServe(":8080", http.HandlerFunc(fileHandler)) | |
} | |
func fileHandler(w http.ResponseWriter, r *http.Request) { | |
fileServer := http.FileServer(http.Dir("static")) | |
log.Printf("url: %s:%s. header = %s", r.Method, r.URL.Path, r.Header) | |
fileServer.ServeHTTP(w, r) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment