ProtoRune.XRPC.Procedure (proto_rune v0.3.0)

Copy Markdown

The XRPC.Procedure module represents a procedure in the XRPC system, encapsulating the method name, request body, and a parser for validating the body. It provides functions to create and manipulate procedure structures.

Overview

This module allows for:

  • Creating Procedures: Use the new/2 function to create a new procedure with a method and a parser.
  • Adding a Body: Use the put_body/2 function to attach a validated body to the procedure.
  • String Representation: The procedure can be converted to a string that represents its full URL.

Functions

new/2

Creates a new procedure with a given method and parser.

XRPC.Procedure.new("app.bsky.actor.mute", from: MyParser)

put_body/2

Attaches a validated body to the procedure.

{:ok, updated_proc} = XRPC.Procedure.put_body(proc, %{"actor_id" => "123"})

Validates the body using the specified parser and updates the procedure via peri.

Summary

Functions

Creates a new procedure with the given method.

Sets the base URL for the procedure.

Attaches a raw binary body to the procedure, skipping schema validation.

Functions

new(method, opts \\ [])

Creates a new procedure with the given method.

Options

Examples

Procedure.new("app.bsky.feed.post")
Procedure.new("app.bsky.feed.post", from: parser, base_url: "https://bsky.social")

put_base_url(proc, base_url)

Sets the base URL for the procedure.

Examples

proc = Procedure.new("app.bsky.feed.post")
proc = Procedure.put_base_url(proc, "https://bsky.social")

put_body(proc, body)

put_header(proc, key, value)

put_raw_body(proc, body)

Attaches a raw binary body to the procedure, skipping schema validation.

Used by endpoints that expect a non-JSON payload, such as com.atproto.repo.uploadBlob.

proc = Procedure.put_raw_body(proc, <<0, 1, 2>>)