Re:Show HN: A simple Go web server with logging, tracing, he...
by sd8dgf8ds8g8dsg on Sunday January 07, 2018 @08:11PM
(#16093915)
static file server in go:
package main
import (
"fmt"
"net/http"
"path/filepath"
)
var (
host = "0.0.0.0"
path = "/var/www/public"
port = 8080
)
func main() {
path, err := filepath.Abs(path)
if err != nil {
panic(err)
}
listenAt := fmt.Sprintf("%s:%v", host, port)
fmt.Println("static-serve-dir serving", path, "over http at", listenAt)
err = http.ListenAndServe(listenAt, http.FileServer(http.Dir(path)))
if err != nil {
panic(err)
}
}
Re:Show HN: A simple Go web server with logging, tracing, he...
by wyattjoh on Sunday January 07, 2018 @03:31PM
(#16092515)
The builtin golang.org/x/crypto/acme/autocert [0] package manages SSL for you easily through Lets Encrypt.
Re:Show HN: A simple Go web server with logging, tracing, he...
by TheDong on Sunday January 07, 2018 @09:05PM
(#16094108)
golang.org/x/ packages are not builtin. You still must download them and use them just as you do any other dependencies, they just share some contribution process and developers with golang's stdlib.
* serving of files and directories
* LetsEncrypt certificates and SSL