package markdown_monolith

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module FetchSource

URI Fetching

This module provides functions to fetch content from URIs, supporting both local file paths and remote HTTP/HTTPS URLs.

  • since 0.1.0

Local File Fetching

Sourceval fetch_local_uri : Uri.t -> (string, string) result

fetch_local_uri uri reads the content of a local file.

  • parameter uri

    A URI with a file:// scheme or no scheme (treated as a local path)

  • returns

    Ok content with the file contents as a string, or Error msg if the file cannot be read

  • since 0.1.0

Remote and Local Fetching

Sourceval fetch_uri_lwt : ?debug:bool -> allow_remote:bool -> Uri.t -> (string, string) result Lwt.t

fetch_uri_lwt ?debug ~allow_remote uri asynchronously fetches content from a URI.

Supports the following URI schemes:

  • No scheme: Treated as a local file path
  • file://: Local file access
  • http:// and https://: Remote HTTP fetching (requires allow_remote = true)
  • parameter debug

    If true, print debug information to stdout (default: false)

  • parameter allow_remote

    If true, permit fetching from HTTP/HTTPS URLs. If false, remote URLs return an error.

  • parameter uri

    The URI to fetch content from

  • returns

    An Lwt promise resolving to Ok content or Error msg

Note: Remote fetches have no built-in timeout. Consider using Lwt.pick with Lwt_unix.timeout for timeout control.

  • since 0.1.0
Sourceval fetch_uri_sync : ?debug:bool -> allow_remote:bool -> Uri.t -> (string, string) result

fetch_uri_sync ?debug ~allow_remote uri synchronously fetches content from a URI.

This is a blocking wrapper around fetch_uri_lwt that runs the Lwt event loop until the fetch completes.

  • parameter debug

    If true, print debug information to stdout (default: false)

  • parameter allow_remote

    If true, permit fetching from HTTP/HTTPS URLs

  • parameter uri

    The URI to fetch content from

  • returns

    Ok content with the fetched content, or Error msg on failure

Warning: This function blocks the current thread. For concurrent fetching, use fetch_uri_lwt directly.

  • since 0.1.0