Skip to main content

parse_order_in

Function parse_order_in 

Source
pub fn parse_order_in(
    q: &ListQuery,
    allowed: &[&str],
) -> Result<Vec<OrderSpec>, String>
Expand description

Parse ?order=, refusing a field this endpoint cannot sort by.

Dropping an unrecognised field silently was the original behaviour, and it was worse than it sounds. Each comparator answers continue for a field it doesn’t know, so an ?order= naming only unknown fields compared every pair Equal; the sort became a no-op and the endpoint’s documented default ordering was discarded along with it. A client that typo’d ?order=titel got neither its ordering nor the default, with nothing said.

Refusing is also what this API already does one endpoint over: /search/?type=bogus is a 400 “so a typo doesn’t look like ‘no matches’”. The same reasoning applies to a typo that looks like “wrong order”.

random is always accepted — it names no field.

§Errors

A message naming the offending field and listing the valid ones.