livegrep/livegrep — pull request #7 by philz (2014-12-18 04:56:30+00:00)
Title: Re-ordering path matching, to prefer path with backend specified.

The backend that I was choosing wasn't being respected.
After confirming (with bin/dump_file) that the backend
should have had the right data (and killing the relevant
backend and not seeing any change) and adding some logging,
I realized that the :backend parameter wasn't being
passed along into api.go.

Based on my reading of pat/mux.go, specifically:

if ph.pat != "/" && len(ph.pat) > 0 && ph.pat[len(ph.pat)-1] == '/' {
return p, true

It seems that any pattern that ends with a slash can match
even if there's random stuff after it. And, yes, the Add()
calls are ordered.

I've tested the /api call manually. The /search path seems
to have the same issue, so I changed that too.