proadocs

package module
v0.0.0-...-392d874 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Proa documentation Go SDK

Official, dependency-free Go client for the public Proa documentation API. Search and read Rust framework documentation without credentials. This package does not scaffold or build applications; use the Proa Rust CLI for that.

Requires Go 1.23 or newer. Install the module with:

go get github.com/Proa-Labs/proa/sdk/go@v0.0.0-20261029004544-c75fce01a7f4
package main

import (
    "context"
    "fmt"
    "log"

    proadocs "github.com/Proa-Labs/proa/sdk/go"
)

func main() {
    client, err := proadocs.NewClient(proadocs.Options{})
    if err != nil { log.Fatal(err) }
    results, err := client.Search(context.Background(), "streaming", proadocs.PageOptions{Limit: 5})
    if err != nil { log.Fatal(err) }
    for _, doc := range results.Results {
        fmt.Println(doc.Title, doc.Path)
    }
}

Search, List, and Get return typed responses. WalkDocuments follows pagination and stops on repeated cursors, context cancellation, or a visitor error. Every request has a 15-second default timeout; Options.Timeout and a caller context can shorten it. A custom HTTPClient supports test transports. Responses are limited to 16 MiB. The client never retries automatically.

Inspect HTTP failures with errors.As(err, &apiError) using a *proadocs.APIError. It preserves StatusCode, the optional Problem, and RetryAfter. Honor that delay for 429 responses. Do not send private data or secrets as documentation search terms.

To read local documentation, run the marketing application from the repository root with cargo proa run -p proa_marketing --bin proa_marketing and set Options.BaseURL to http://localhost:5555. Custom deployments may use a base path prefix; the client preserves it for every API request.

Run go test -race ./... and go vet ./... in this directory. The tests use local HTTP servers and require no credentials or live API access.

Documentation

Overview

Package proadocs is the official Go client for Proa's public documentation API.

Search and read Rust framework documentation at https://proa.so/docs/api. No credentials are required. This client does not build or deploy applications.

Index

Constants

View Source
const DefaultBaseURL = "https://proa.so"

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Problem    *Problem
	RetryAfter *time.Duration
}

APIError preserves the HTTP status, optional problem document, and retry delay. The client never retries automatically. Use errors.As to inspect this error.

func (*APIError) Error

func (e *APIError) Error() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is safe for concurrent use when its supplied HTTPClient is too.

func NewClient

func NewClient(options Options) (*Client, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string) (*Document, error)

func (*Client) List

func (c *Client) List(ctx context.Context, options PageOptions) (*DocumentList, error)

func (*Client) Search

func (c *Client) Search(ctx context.Context, query string, options PageOptions) (*DocumentList, error)

func (*Client) WalkDocuments

func (c *Client) WalkDocuments(ctx context.Context, visit func(DocumentSummary) error) error

WalkDocuments visits every public document, following pagination with batches of 50. Return an error from visit or cancel ctx to stop. Repeated or empty continuation cursors are rejected rather than looping indefinitely.

type Document

type Document struct {
	DocumentSummary
	Markdown string `json:"markdown"`
}

type DocumentList

type DocumentList struct {
	Results    []DocumentSummary `json:"results"`
	Total      int               `json:"total"`
	NextCursor *string           `json:"next_cursor"`
}

type DocumentSummary

type DocumentSummary struct {
	Title       string `json:"title"`
	Path        string `json:"path"`
	MarkdownURL string `json:"markdown_url"`
	Description string `json:"description"`
}

type Options

type Options struct {
	BaseURL    string
	Timeout    time.Duration
	HTTPClient *http.Client
}

Options configures a client. Zero values select production, a 15-second per-request timeout, and the default HTTP transport. A base URL can include a path prefix, for example https://example.com/docs-service.

type PageOptions

type PageOptions struct {
	Limit  int
	Cursor *string
}

PageOptions controls pagination. Limit zero uses the server default (10). Reuse a returned NextCursor only with the same query and deployment.

type Problem

type Problem struct {
	Type          string `json:"type"`
	Title         string `json:"title"`
	Status        int    `json:"status"`
	Code          string `json:"code"`
	Detail        string `json:"detail"`
	Documentation string `json:"documentation"`
}

Jump to

Keyboard shortcuts

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