The unavailability of GitLab API makes us fallback to disk-serving
Currently, if the GitLab API is unavailable we fallback to using disk serving
.
This is OK, now, but in a fully cloud-native architecture, this should rather
return a proper 500
type of error.
We should disable local instance()
and instead return a proper error to client.
func (d *Domain) resolve(r *http.Request) *serving.Request {
request, _ := d.Resolver.Resolve(r)
// TODO improve code around default serving, when `disk` serving gets removed
// https://gitlab.com/gitlab-org/gitlab-pages/issues/353
if request == nil {
return &serving.Request{Serving: local.Instance()}
}
return request
}
// ServeFileHTTP returns true if something was served, false if not.
func (d *Domain) ServeFileHTTP(w http.ResponseWriter, r *http.Request) bool {
if !d.HasLookupPath(r) {
// TODO: this seems to be wrong: as we should rather return false, and
// fallback to `ServeNotFoundHTTP` to handle this case
httperrors.Serve404(w)
return true
}
request := d.resolve(r)
return request.ServeFileHTTP(w, r)
}
Edited by Kamil Trzciński