aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2019-03-07 13:53:53 -0500
committerB Stack <bgstack15@gmail.com>2019-03-07 13:53:53 -0500
commit342db92d849f73ba03d7bda7d2b851e98f8bdf0c (patch)
treebd25b64d4da3e3bfe10bc2dec3214ac02ffd7f9e
parentUpdate README with blog link (diff)
downloadsleepy-https.tar.gz
sleepy-https.tar.bz2
sleepy-https.zip
WIP: add tls serverhttps
-rw-r--r--core.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/core.go b/core.go
index 631d76d..2df40b7 100644
--- a/core.go
+++ b/core.go
@@ -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())
}
bgstack15