From 342db92d849f73ba03d7bda7d2b851e98f8bdf0c Mon Sep 17 00:00:00 2001 From: B Stack Date: Thu, 7 Mar 2019 13:53:53 -0500 Subject: WIP: add tls server --- core.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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()) } -- cgit