oRPC

Configuration

Config structs, YAML examples, and option helpers for oRPC

YAML Configuration Example

config.yaml
extensions:
  orpc:
    enabled: true
    endpoint: "/rpc"
    openRPCEndpoint: "/rpc/schema"
    serverName: "my-app"
    serverVersion: "1.0.0"

    # Auto-exposure
    autoExposeRoutes: true
    methodPrefix: ""
    excludePatterns:
      - "/_/*"
    includePatterns: []
    namingStrategy: "path"           # "path", "method", or "custom"

    # Features
    enableOpenRPC: true
    enableDiscovery: true
    enableBatch: true
    batchLimit: 10

    # Security
    requireAuth: false
    authHeader: "Authorization"
    rateLimitPerMinute: 0            # 0 = unlimited

    # Limits
    maxRequestSize: 1048576          # 1 MB
    requestTimeout: 30               # seconds

    # Performance
    schemaCache: true
    enableMetrics: true

The extension loads config from extensions.orpc first, falling back to orpc.

Programmatic Configuration

ext := orpc.NewExtension(
    orpc.WithEndpoint("/api/rpc"),
    orpc.WithAutoExpose(true),
    orpc.WithMethodPrefix("myapp."),
    orpc.WithBatch(true, 20),
    orpc.WithNamingStrategy("path"),
)

Config Struct Reference

Config

FieldTypeDefaultDescription
EnabledbooltrueEnable the extension
Endpointstring"/rpc"JSON-RPC endpoint
OpenRPCEndpointstring"/rpc/schema"OpenRPC schema endpoint
ServerNamestring"forge-app"Server name for OpenRPC
ServerVersionstring"1.0.0"Server version
AutoExposeRoutesbooltrueAuto-expose HTTP routes as methods
MethodPrefixstring""Prefix for generated method names
ExcludePatterns[]string["/_/*"]Route patterns to exclude
IncludePatterns[]string[]Route patterns to include (whitelist)
EnableOpenRPCbooltrueGenerate OpenRPC schema
EnableDiscoverybooltrueEnable method discovery endpoint
EnableBatchbooltrueEnable batch requests
BatchLimitint10Maximum batch size
NamingStrategystring"path"Method naming: path, method, custom
RequireAuthboolfalseRequire authentication
AuthHeaderstring"Authorization"Auth header name
RateLimitPerMinuteint0Rate limit (0 = unlimited)
MaxRequestSizeint641048576 (1 MB)Maximum request size
RequestTimeoutint30Request timeout in seconds
SchemaCachebooltrueCache generated schemas
EnableMetricsbooltrueEnable metrics

Option Helpers

FunctionDescription
WithEnabled(enabled)Toggle the extension
WithEndpoint(endpoint)Set the RPC endpoint path
WithAutoExpose(enabled)Toggle auto-exposure of HTTP routes
WithMethodPrefix(prefix)Set method name prefix
WithExcludePatterns(patterns...)Set route exclude patterns
WithIncludePatterns(patterns...)Set route include patterns
WithBatch(enabled, limit)Toggle batch support with limit
WithNamingStrategy(strategy)Set method naming strategy
WithAuth(header, tokens...)Enable authentication
WithRateLimit(perMinute)Set rate limit
WithConfig(config)Provide a complete config struct

How is this guide?

On this page