Refactor middleware to stop resolving a domain name when is not needed

We don't need to resolve a domain's configuration for every request, some cases are:

  • when r.Host == --pages-domain
  • when proxying artifacts r.Path contains /-/

This happens due to the order of middleware execution, see gitlab#25192 (comment 678799178) for details.


The following discussion from !585 (merged) should be addressed:

  • @jaime started a discussion: (+2 comments)

    I would love to fix gitlab#25192 (comment 678799178) here, where we try to resolve a domain as the first thing in the request chain, and sometimes is not necessary, for example when proxying artifacts.

Related MR !554 (closed)