go>> gssc>> 返回
项目作者: mh-cbon

项目描述 :
Easily starts an HTTPS server with self-signed certificates
高级语言: Go
项目地址: git://github.com/mh-cbon/gssc.git
创建时间: 2016-11-09T11:21:41Z
项目社区:https://github.com/mh-cbon/gssc

开源协议:MIT License

下载


gssc

GoDoc

Easily starts an HTTPS server with self-signed certificates.

Install

  1. go get github.com/mh-cbon/gssc
  2. glide install github.com/mh-cbon/gssc

Usage

  1. package main
  2. import (
  3. "net/http"
  4. "crypto/tls"
  5. "time"
  6. "github.com/mh-cbon/gssc"
  7. )
  8. var port = ":8080"
  9. var domain = "example.org"
  10. // Example_main demonstrates usage of gssc package.
  11. func main() {
  12. s := &http.Server{
  13. Handler: &ww{},
  14. Addr: port,
  15. WriteTimeout: 15 * time.Second,
  16. ReadTimeout: 15 * time.Second,
  17. TLSConfig: &tls.Config{
  18. InsecureSkipVerify: true,
  19. GetCertificate: gssc.GetCertificate(domain),
  20. },
  21. }
  22. s.ListenAndServeTLS("", "")
  23. }
  24. type ww struct{}
  25. func (s *ww) ServeHTTP(w http.ResponseWriter, req *http.Request) {
  26. w.Header().Set("Content-Type", "text/plain")
  27. w.Write([]byte("This is an example server.\n"))
  28. }

Credits - read more