# Eyre

Eyre is Arvo's HTTP server module.

HTTP requests come in from clients (web frontends, mobile apps, etc.) and Eyre produces HTTP responses. Eyre has a number of ways to handle such HTTP requests which we'll briefly describe.

## Authentication <a href="#authentication" id="authentication"></a>

Most types of HTTP request require the client to provide a valid session cookie, which is given to the client by the ship when the user logs in with their web login code. This process is documented in the [Authentication](/urbit-os/kernel/eyre/external-api-ref.md#authentication) section of Eyre's [External API Reference](/urbit-os/kernel/eyre/external-api-ref.md).

## The Channel System <a href="#the-channel-system" id="the-channel-system"></a>

An Eyre channel is a Server Sent Event (SSE) stream. It's the primary way of interacting with Urbit apps from outside Urbit, because it provides a simple JSON API that allows you to send data to apps

Eyre's "channel" system is the primary way of interacting with Urbit apps from clients outside of Urbit. It provides a simple JSON API that allows you to send data to apps, and a [Server Sent Event](https://html.spec.whatwg.org/#server-sent-events) (SSE) stream to subscribe to updates from a backend on the Urbit ship.

Detailed documentation of the channel system's JSON API is provided in Eyre's [External API Reference](/urbit-os/kernel/eyre/external-api-ref.md), with corresponding examples in the [Guide](/urbit-os/kernel/eyre/guide.md#using-channels) document.

## Scrying <a href="#scrying" id="scrying"></a>

You can make read-only requests to Eyre with HTTP GET requests or scries. Eyre's scry interface documented in the [Scry](/urbit-os/kernel/eyre/external-api-ref.md#scry) section of the [External API Reference](/urbit-os/kernel/eyre/external-api-ref.md).

## Threads <a href="#threads" id="threads"></a>

You can also run threads directly through Eyre via HTTP request. The [API for this](/urbit-os/base/threads/http-api.md) is not part of Eyre itself, so is documented in the seperate [Threads](/urbit-os/base/threads.md) section.

## Generators <a href="#generators" id="generators"></a>

Generators (Hoon scripts) can also be used by clients via Eyre. These don't have a JSON API, but handle HTTP requests and return HTTP responses directly.

This usage is uncommon, but is explained in the [`%serve`](/urbit-os/kernel/eyre/tasks.md#serve) section of Eyre's [Internal API Reference](/urbit-os/kernel/eyre/tasks.md). A practical example is provided in the [Generators](/urbit-os/kernel/eyre/guide.md#generators) section of the Eyre [guide](/urbit-os/kernel/eyre/guide.md).

## Direct HTTP Handling With Gall Agents <a href="#direct-http-handling-with-gall-agents" id="direct-http-handling-with-gall-agents"></a>

As well as the [Channel System](#the-channel-system) and [Scries](#scrying), it's also possible for Urbit apps to deal directly with HTTP requests using their own developer-defined logic.

This method is explained in the [`%connect`](/urbit-os/kernel/eyre/tasks.md#connect) section of Eyre's [Internal API Reference](/urbit-os/kernel/eyre/tasks.md) document; a detailed example is provided in the [Agents: Direct HTTP](/urbit-os/kernel/eyre/guide.md#agents-direct-http) section of the Eyre [guide](/urbit-os/kernel/eyre/guide.md).

## Cross-Origin Resource Sharing (CORS) <a href="#cross-origin-resource-sharing" id="cross-origin-resource-sharing"></a>

Eyre supports both simple [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) requests and OPTIONS preflight requests. Eyre has a CORS registry with three categories: `approved`, `rejected` and `requests`. Eyre will respond positively for origins in its `approved` list, and negatively for all others. If a request comes in that isn't from an `approved` or `rejected` origin, Eyre will add that origin to the `requests` list. Eyre always allows all methods and headers over CORS.

This is documented in [Managing CORS Origins](/urbit-os/kernel/eyre/guide.md#managing-cors-origins).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.urbit.org/urbit-os/kernel/eyre.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
