README.md

# Davy

A Plug-based library for building WebDAV-compatible file servers in Elixir.

Davy handles the WebDAV HTTP protocol (RFC 4918) — PROPFIND/PROPPATCH XML
processing, multistatus responses, COPY/MOVE semantics, locking, and client
compatibility — and delegates actual storage operations to a user-provided
backend module implementing the `Davy.Backend` behaviour.

## Installation

Add `davy` to your dependencies:

```elixir
def deps do
  [{:davy, "~> 0.3.1"}]
end
```

## Quick start

1. Implement the `Davy.Backend` behaviour
2. Mount `Davy.Plug` in your router:

```elixir
forward "/dav", Davy.Plug, backend: MyApp.DavBackend
```

## Features

- **Class 1 and 2 WebDAV compliance** — all required methods including locking
- **Pluggable backend** — implement a behaviour to connect any storage system
- **Client compatibility** — handles macOS Finder, Windows Explorer, and davfs2 quirks
- **Namespace-aware XML** — correct handling of DAV: namespace with arbitrary prefixes
- **Pluggable lock store** — built-in ETS store or provide your own for distributed locking

## Supported methods

| Method | Description |
|--------|-------------|
| OPTIONS | Capability discovery |
| GET / HEAD | Read file content |
| PUT | Create or replace files |
| DELETE | Remove resources (recursive for collections) |
| MKCOL | Create collections (directories) |
| COPY | Copy resources |
| MOVE | Move/rename resources |
| PROPFIND | Retrieve resource properties |
| PROPPATCH | Modify resource properties |
| LOCK | Acquire write locks |
| UNLOCK | Release write locks |

## Telemetry

Davy emits [`:telemetry`](https://hexdocs.pm/telemetry) spans for every
request, every backend callback, and every lock store call. Attach handlers
to measure latency, count error codes, or integrate with
`telemetry_metrics`.

Event namespaces:

- `[:davy, :request, :start | :stop | :exception]`
- `[:davy, :backend, <callback>, :start | :stop | :exception]`
- `[:davy, :lock_store, <callback>, :start | :stop | :exception]`

See `Davy.Telemetry` for the full event catalogue, measurements and metadata.

## References

- [RFC 4918 — WebDAV](https://www.rfc-editor.org/rfc/rfc4918)

## GitHub Mirror

Eventually, [Forgejo](https://www.forgejo.org) will support fully federated operation, but for now there's a [mirror of this repository on GitHub](https://www.github.com/jimsynz/davy) - feel free to open issues and PRs there.

## Licence

[Apache-2.0](LICENSE)