# Lua, handlers, and triggers

Put Lua in named `<handler>` elements and reusable snippets in named `<library>`
elements. CDATA preserves the source exactly. The optional `<on-message>` entry
point handles cloud invocation. Handler and library names are unique.

Triggers connect an event or schedule to a handler. Cron triggers declare a
schedule. Tail and file-watch triggers declare paths, with an optional pattern
for file-created and file-deleted events. Every trigger must name an existing
handler. Validation checks Lua syntax and references to the resources declared
in this definition.

This example is rejected because a route names a handler the definition does not
provide.

```xml
<edge-app format="1" handle="invalid-handler" name="Invalid handler">
  <http-routes>
    <route method="post" path="/events" handler="missing">
      <auth mode="none"/>
    </route>
  </http-routes>
</edge-app>
```