This match is technically a partial function according as far as the type system is concerned. Are you certain you'll only get "json" and "html" for format, otherwise you might get a matchError at runtime. If that is the case might be better to describe that in the types - have a JSON and HTML as the only possible types for this match (e.g. via a sealed trait).