url: Filtering for list (#116)

This commit is contained in:
Janos Dobronszki
2021-05-19 18:00:53 +01:00
committed by GitHub
parent 90186703f9
commit 869f7d3deb

View File

@@ -84,7 +84,12 @@ func (e *Url) List(ctx context.Context, req *url.ListRequest, rsp *url.ListRespo
}
rsp.UrlPairs = []*url.URLPair{}
err := e.pairs.Read(e.ownerIndex.ToQuery(tenantID), &rsp.UrlPairs)
var err error
if req.ShortURL != "" {
err = e.pairs.Read(model.QueryEquals("shortURL", req.ShortURL), &rsp.UrlPairs)
} else {
err = e.pairs.Read(e.ownerIndex.ToQuery(tenantID), &rsp.UrlPairs)
}
if err != nil {
return err
}