diff options
author | dev <navdgo@gmail.com> | 2019-05-14 10:35:41 -0400 |
---|---|---|
committer | dev <navdgo@gmail.com> | 2019-05-20 14:48:26 -0400 |
commit | 043eb1d9e5db456b9b78c0423cb44716fc81a932 (patch) | |
tree | a78aee0752b03c4f3c3cb45d409107e64faa10e3 /modules/caddyhttp/caddyhttp.go | |
parent | fec7fa8bfda713e8042b9bbf9a480c7792b78c41 (diff) |
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()
Diffstat (limited to 'modules/caddyhttp/caddyhttp.go')
-rw-r--r-- | modules/caddyhttp/caddyhttp.go | 13 |
1 files changed, 12 insertions, 1 deletions
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 { |