From 043eb1d9e5db456b9b78c0423cb44716fc81a932 Mon Sep 17 00:00:00 2001 From: dev Date: Tue, 14 May 2019 10:35:41 -0400 Subject: move internal packages to pkg folder and update reverse proxy * set automatic https error type for cert-magic failures * add state to onload and unload methods * update reverse proxy to use Provision() and Cleanup() --- modules/caddyhttp/caddyhttp.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'modules/caddyhttp/caddyhttp.go') diff --git a/modules/caddyhttp/caddyhttp.go b/modules/caddyhttp/caddyhttp.go index 449d07f..379c8f2 100644 --- a/modules/caddyhttp/caddyhttp.go +++ b/modules/caddyhttp/caddyhttp.go @@ -24,6 +24,7 @@ func init() { Name: "http", New: func() (interface{}, error) { return new(App), nil }, }) + if err != nil { log.Fatal(err) } @@ -94,11 +95,21 @@ func (app *App) Validate() error { return nil } +// AutomaticHTTPSError represents an error received when attempting to enable automatic https. +type AutomaticHTTPSError struct { + internal error +} + +// Error returns the error string for automaticHTTPSError. +func (a AutomaticHTTPSError) Error() string { + return fmt.Sprintf("enabling automatic HTTPS: %v", a.internal.Error()) +} + // Start runs the app. It sets up automatic HTTPS if enabled. func (app *App) Start() error { err := app.automaticHTTPS() if err != nil { - return fmt.Errorf("enabling automatic HTTPS: %v", err) + return &AutomaticHTTPSError{internal: err} } for srvName, srv := range app.Servers { -- cgit v1.2.3