Skip to main content

Modifying responses

When a Runnable is used to handle an HTTP request, Atmo will bind that request to the Runnable. The resp namespace of the Runnable API can then be used to modify the response that Atmo will send to the caller.

In Rust these methods are available under the resp module:

# Use the "resp" module
use suborbital::resp;

# Invoke the "SetHeader" method
resp::set_header(…)

The following namespace methods are available:

Set header​

Sets an HTTP response header:

pub fn set_header(key: &str, val: &str)

Content-Type​

An alias of set_header that allows easily setting the response Content-Type:

pub fn content_type(ctype: &str)