3 ms·
Nice. Does anyone have a server like this but with the addition of * serving of files and directories * LetsEncrypt certificates and SSL
by skanga 9y ago
Nice. Does anyone have a server like this but with the addition of
* serving of files and directories
* LetsEncrypt certificates and SSL
- deleted 9y ago[deleted]
- wyattjoh 9y agoThe builtin golang.org/x/crypto/acme/autocert [0] package manages SSL for you easily through Lets Encrypt. [0]: https://godoc.org/golang.org/x/crypto/acme/autocert https://godoc.org/golang.org/x/crypto/acme/autocert
- TheDong 9y agogolang.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.
- sd8dgf8ds8g8dsg 9y agostatic 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) } }