http

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package http is the HTTP output of docflow: the kind http, shown as HTTP (push), sends what reaches the node to a web service in a request (a downloader is where applications fetch documents instead). A program that imports the package has the kind; docflow/io/notify posts its webhooks with Do.

The node's URL expands {{meta.<key>}} (each value URL-escaped), its Method is POST (the default) or PUT, and its Headers expand {{meta.<key>}} too, without line breaks. Its credential is the request's Authorization: a token sent as Bearer, or a whole value with its scheme ("Basic …"). Its Body is how the request carries the document and the sender's metadata:

  • direct (the default): the document is the body, as it is, its name in Content-Disposition, and the metadata goes along as X-Meta-<key> headers (2026-10-21).
  • multipart: the body is multipart/form-data, the metadata a JSON object in the part meta, then the document in the part file, with its name and type (2026-10-23).

Another docflow's uploader (POST /api/upload/<node>, with its key or an app's token as the credential) takes either as its sender's: .bdf goes to another site as it is, with its name and metadata.

Every request has an Idempotency-Key, the delivery's id, the same on every try (a send is at least once). 2xx is done; 408, 429 and 5xx are tried again; any other answer, a redirect too, fails for good.

Index

Constants

View Source
const (
	// BodyDirect sends the document as the body, the metadata in
	// X-Meta-* headers.
	BodyDirect = "direct"
	// BodyMultipart sends multipart/form-data: the metadata as JSON in
	// the part meta, the document in the part file.
	BodyMultipart = "multipart"
)

The ways a request carries the document (Node.Body).

View Source
const KindHTTP = "http"

KindHTTP is the kind of the HTTP output.

Variables

View Source
var Client = &nethttp.Client{Timeout: 2 * time.Minute, CheckRedirect: func(*nethttp.Request, []*nethttp.Request) error { return nethttp.ErrUseLastResponse }}

Client makes the requests (tests set their own). It follows no redirect.

Functions

func CheckURL

func CheckURL(raw string) error

CheckURL takes an http or https URL (that may expand {{meta.<key>}}).

func Do

func Do(ctx context.Context, m *docflow.Manager, r *Request) (string, error)

Do sends a request, and tells its status: 2xx is nil, 408, 429 and 5xx an error tried again, any other a final one.

Types

type Request

type Request struct {
	Method, URL string
	Header      nethttp.Header
	Body        []byte
	// Credential names the Authorization's value (Node.Credential).
	Credential string
	// Key is the Idempotency-Key.
	Key string
}

Request is a request Do sends.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL