diff options
author | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-07-02 18:14:40 +0300 |
---|---|---|
committer | Tuomo Ala-Vannesluoma <tuomoav@gmail.com> | 2018-07-02 18:14:40 +0300 |
commit | 415f4224b04c631588fba386687e69b47cae9be4 (patch) | |
tree | 2ffefeaac5cecf81c2c7f97eeabace43915eeb26 /internal/domain | |
parent | e9253d07ddad509465d64ca58400e527bc378da9 (diff) |
Get rid of panic serving errors
Diffstat (limited to 'internal/domain')
-rw-r--r-- | internal/domain/domain.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/internal/domain/domain.go b/internal/domain/domain.go index bf0129c8..e32ba097 100644 --- a/internal/domain/domain.go +++ b/internal/domain/domain.go @@ -110,6 +110,10 @@ func (d *D) getProject(r *http.Request) *project { // IsHTTPSOnly figures out if the request should be handled with HTTPS // only by looking at group and project level config. func (d *D) IsHTTPSOnly(r *http.Request) bool { + if d == nil { + return false + } + if d.config != nil { return d.config.HTTPSOnly } @@ -125,6 +129,10 @@ func (d *D) IsHTTPSOnly(r *http.Request) bool { // IsAccessControlEnabled figures out if the request is to a project that has access control enabled func (d *D) IsAccessControlEnabled(r *http.Request) bool { + if d == nil { + return false + } + project := d.getProject(r) if project != nil { @@ -337,6 +345,11 @@ func (d *D) EnsureCertificate() (*tls.Certificate, error) { // ServeHTTP implements http.Handler. func (d *D) ServeHTTP(w http.ResponseWriter, r *http.Request) { + if d == nil { + httperrors.Serve404(w) + return + } + if d.config != nil { d.serveFromConfig(w, r) } else { |