Primate
Guides Responses

Serve plain text

Return strings to serve plain text responses. Primate sets Content-Type: text/plain on returned string.

Strings are served as text; use response.text() for granular control.

Return string

Primate sets Content-Type: text/plain on returned string.

TypeScriptroutes/hello.ts
import route from "primate/route";

route.get(() => "Hello, World!");```


Explicit text response

Use response.text() for custom options.

TypeScriptroutes/index.ts
import response from "primate/response";
import route from "primate/route";

route.get(() => response.text("Not found", { status: 404 }));

Custom content type

Specify MIME type.

TypeScriptroutes/index.ts
import response from "primate/response";
import route from "primate/route";

route.get(() => response("Custom text", {
  headers: { "Content-Type": "text/custom" },
}));