caddy_browse

Types

pub type BrowseData {
  Listing(files: List(File))
}

Constructors

  • Listing(files: List(File))
pub type BrowseError {
  UnexpectedStatus
  UnexpectedBody(json.DecodeError)
}

Constructors

pub type Direction {
  Ascending
  Descending
}

Constructors

  • Ascending
  • Descending
pub type File {
  File(
    name: String,
    size: Int,
    url: String,
    modification_time: timestamp.Timestamp,
    mode: Int,
    is_directory: Bool,
    is_symlink: Bool,
  )
}

Constructors

  • File(
      name: String,
      size: Int,
      url: String,
      modification_time: timestamp.Timestamp,
      mode: Int,
      is_directory: Bool,
      is_symlink: Bool,
    )

Values

pub fn request(
  req: request.Request(anything),
) -> request.Request(anything)

Update a request to the Caddy file server’s browse directory to set the accept header to application/json, so it can be parsed by the response function.

let assert Ok(request) = request.to("https://example.com/some/path")
let request = caddy_browse.request(request)
your_http_client.send(request)
pub fn response(
  response: response.Response(String),
) -> Result(BrowseData, BrowseError)

Decode a response returned by the Caddy file server’s browse directory listing.

pub fn sort_by_modification_time(
  req: request.Request(anything),
  direction: Direction,
) -> request.Request(anything)

Update a request to the Caddy file server’s browse directory to set the accept header to application/json (so it can be parsed by the response function) and setting the listed files to be ordered by their modification time.

let assert Ok(request) = request.to("https://example.com/some/path")
let request = caddy_browse.sort_by_modification_time(request)
your_http_client.send(request)
pub fn sort_by_name(
  req: request.Request(anything),
  direction: Direction,
) -> request.Request(anything)

Update a request to the Caddy file server’s browse directory to set the accept header to application/json (so it can be parsed by the response function) and setting the listed files to be ordered by their name.

let assert Ok(request) = request.to("https://example.com/some/path")
let request = caddy_browse.sort_by_name(request)
your_http_client.send(request)
pub fn sort_by_size(
  req: request.Request(anything),
  direction: Direction,
) -> request.Request(anything)

Update a request to the Caddy file server’s browse directory to set the accept header to application/json (so it can be parsed by the response function) and setting the listed files to be ordered by their size.

let assert Ok(request) = request.to("https://example.com/some/path")
let request = caddy_browse.sort_by_size(request)
your_http_client.send(request)
pub fn sort_by_type_then_name(
  req: request.Request(anything),
  direction: Direction,
) -> request.Request(anything)

Update a request to the Caddy file server’s browse directory to set the accept header to application/json (so it can be parsed by the response function) and setting the listed files to be ordered by their type (file or directory) and then their name.

let assert Ok(request) = request.to("https://example.com/some/path")
let request = caddy_browse.sort_by_type_then_name(request)
your_http_client.send(request)
Search Document