diff options
author | B Stack <bgstack15@gmail.com> | 2019-03-07 13:53:53 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2019-03-07 13:53:53 -0500 |
commit | 342db92d849f73ba03d7bda7d2b851e98f8bdf0c (patch) | |
tree | bd25b64d4da3e3bfe10bc2dec3214ac02ffd7f9e | |
parent | Update README with blog link (diff) | |
download | sleepy-https.tar.gz sleepy-https.tar.bz2 sleepy-https.zip |
WIP: add tls serverhttps
-rw-r--r-- | core.go | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -164,5 +164,14 @@ func (api *API) Start(port int) error { return errors.New("You must add at least one resource to this API.") } portString := fmt.Sprintf(":%d", port) - return http.ListenAndServe(portString, api.Mux()) + return http.ListenAndServeTLS(portString, "/home/bgirton/dev/c1/gocert.crt", "/home/bgirton/dev/c1/gocert.key", api.Mux()) +} + +// StartTLS causes the API to begin serving requests on the given port with TLS. +func (api *API) StartTLS(port int, certFile, keyFile string) error { + if !api.muxInitialized { + return errors.New("You must add at least one resource to this API.") + } + portString := fmt.Sprintf(":%d", port) + return http.ListenAndServeTLS(portString, certFile, keyFile, api.Mux()) } |