diff options
Diffstat (limited to 'core.go')
-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()) } |