Caddy.Admin.Request (Caddy v2.3.1)

View Source

Low-level HTTP client for Caddy Admin API.

This module provides direct HTTP communication with the Caddy admin API using either Unix domain sockets or TCP connections. It implements the RequestBehaviour and handles GET, POST, PUT, PATCH, and DELETE operations.

Implementation Details

  • Uses Caddy.Admin.Transport for connection management
  • Supports both Unix sockets (embedded mode) and TCP (external mode)
  • Parses HTTP responses with :http_bin packet mode
  • Automatically decodes JSON responses
  • Returns structured response with status, headers, and body

Summary

Functions

Send HTTP GET method to admin API

Send HTTP PATCH method to admin API

Send HTTP POST method to admin API

Send HTTP PUT method to admin API

Types

t()

@type t() :: %Caddy.Admin.Request{
  body: binary(),
  headers: Keyword.t(),
  status: integer()
}

Functions

delete(path, data \\ "", content_type \\ "application/json")

@spec delete(binary(), binary(), binary()) ::
  {:ok, atom() | %{:headers => list(), optional(any()) => any()},
   String.t() | map()}

Send HTTP DELETE method to admin API

get(path)

Send HTTP GET method to admin API

patch(path, data, content_type \\ "application/json")

Send HTTP PATCH method to admin API

post(path, data, content_type \\ "application/json")

Send HTTP POST method to admin API

put(path, data, content_type \\ "application/json")

@spec put(binary(), binary(), binary()) ::
  {:ok, atom() | %{:headers => list(), optional(any()) => any()},
   String.t() | map()}

Send HTTP PUT method to admin API