# Complete example

This configuration starts an API and a worker from one Cargo workspace. The API must listen on port 3000. Replace `WORKSPACE-ID` and `app.example.com`, configure the CNAME, and create the shared `ADMIN_PASSWORD_HASH` variable as described above. The two hostnames serve the same API; the worker needs no HTTP binding.

```json
{
  "packages": {
    "api": {
      "args": [],
      "restart": {
        "policy": "on-failure",
        "max_restarts": 5,
        "delay_secs": 1
      }
    },
    "worker": {
      "args": [],
      "restart": {
        "policy": "always",
        "max_restarts": 10,
        "delay_secs": 3
      }
    }
  },
  "http": {
    "binds": {
      "WORKSPACE-ID.aloha.leilani.dev": 3000,
      "app.example.com": 3000
    },
    "max_body_size": 1048576,
    "static_dir": "./public"
  },
  "users": [
    {
      "username": "admin",
      "password": "${ADMIN_PASSWORD_HASH}",
      "roles": ["admin"],
      "xref_id": "customer-123"
    }
  ],
  "rules": [
    {
      "priority": 0,
      "hosts": [
        "WORKSPACE-ID.aloha.leilani.dev",
        "app.example.com"
      ],
      "methods": ["GET", "HEAD", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"],
      "path": "^/admin(?:/.*)?$",
      "roles": ["admin"]
    }
  ]
}
```

The listed methods on `/admin` and its child paths require the admin role on both hostnames, including matching static files. Other paths and methods remain public at the Leilani proxy. Extend the method list if your application accepts additional methods.
