Skip to main content

content_type_for

Function content_type_for 

Source
pub fn content_type_for(path: &str) -> &'static str
Expand description

★ THE MIME TABLE LIVES IN ONE PLACE, AND THAT PLACE IS static.lg. ★

A content type decides whether a browser RUNS a file, renders it, or downloads it — so it is not cosmetic: a stylesheet typed text/plain is ignored, a wasm module typed application/octet-stream fails instantiateStreaming, and a page with no charset renders a visitor’s name as mojibake.

TWO different things ask the question. A DEPLOYED LOGOS program answers it by calling static.lg’s contentTypeFor; largo serve and largo build answer it as the tool assembling a site. When those were two tables they had already DRIFTED — text/css against text/css; charset=utf-8, and six types the LOGOS side did not know at all, so a deployed site served its own fonts as application/octet-stream. A file typed one way in development and another in production is the single worst place for a difference to appear.

So there is ONE table and the tool READS IT, rather than two tables held in agreement by a test. static.lg is the source because framework logic belongs in LOGOS, where every tier runs it; adding a type there is the only edit an author ever makes, and largo picks it up with no second place to remember.