aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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