oRPC
Functions
Public API reference for the oRPC extension
| Function | Description |
|---|
NewExtension(opts ...ConfigOption) forge.Extension | Create the oRPC extension with functional options |
NewExtensionWithConfig(config Config) forge.Extension | Create the oRPC extension with a complete config |
DefaultConfig() Config | Returns the default configuration |
| Method | Description |
|---|
RegisterMethod(method Method) error | Register a JSON-RPC method manually |
GetMethod(name) (*Method, error) | Get a registered method by name |
ListMethods() []Method | List all registered methods |
GenerateMethodFromRoute(route) (*Method, error) | Generate a method from a Forge HTTP route |
| Method | Description |
|---|
HandleRequest(ctx, request) *Response | Process a single JSON-RPC request |
HandleBatch(ctx, requests) []*Response | Process a batch of JSON-RPC requests |
| Method | Description |
|---|
OpenRPCDocument() *OpenRPCDocument | Generate the OpenRPC schema document |
| Method | Description |
|---|
Use(middleware...) | Add middleware to the processing pipeline |
GetStats() *ServerStats | Get server statistics |
SetRouter(router) | Set the Forge router for route execution |
| Function | Description |
|---|
NewSuccessResponse(id, result) *Response | Create a success response |
NewErrorResponse(id, code, message) *Response | Create an error response |
NewErrorResponseWithData(id, code, message, data) *Response | Create an error response with additional data |
GetErrorMessage(code) string | Get the standard message for a JSON-RPC error code |
| Field | Type | Purpose |
|---|
Name | string | Method name (e.g. create.users) |
Description | string | Human-readable description |
Handler | MethodHandler | Function to execute |
Params | *ParamsSchema | Parameter schema |
Result | *ResultSchema | Result schema |
Tags | []string | Categorization tags |
| Field | Type | Purpose |
|---|
JSONRPC | string | Protocol version (always "2.0") |
Method | string | Method name to invoke |
Params | json.RawMessage | Method parameters |
ID | any | Request identifier |
| Field | Type | Purpose |
|---|
JSONRPC | string | Protocol version |
Result | any | Success result |
Error | *Error | Error object (if failed) |
ID | any | Request identifier |
How is this guide?