1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-17 20:28:06 +02:00

support for tls on http plugin (#2126)

This commit is contained in:
Alex Unger 2021-02-17 19:20:06 +01:00 committed by GitHub
parent f9f5e7422d
commit 0f0ace1a44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
package http
import (
"crypto/tls"
"errors"
"fmt"
"net"
@ -236,7 +237,17 @@ func (h *httpServer) Start() error {
hd := h.hd
h.Unlock()
ln, err := net.Listen("tcp", opts.Address)
var (
ln net.Listener
err error
)
if opts.TLSConfig != nil {
ln, err = tls.Listen("tcp", opts.Address, opts.TLSConfig)
} else {
ln, err = net.Listen("tcp", opts.Address)
}
if err != nil {
return err
}
@ -307,6 +318,9 @@ func (h *httpServer) Stop() error {
}
func (h *httpServer) String() string {
if h.opts.TLSConfig != nil {
return "https"
}
return "http"
}