proxy

package
v0.0.1-beta.8 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2025 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

This file contains the common plugin processing logic for XRP. It provides a generic framework for processing any document type (HTML, XML) with plugins while maintaining type safety and consistent error handling.

Package proxy implements the core HTTP reverse proxy functionality for XRP.

This package provides an HTTP-aware reverse proxy that can intercept and modify HTML and XML responses using a plugin system. The proxy supports:

- Intelligent Redis-based caching with HTTP compliance - Plugin-based content modification for HTML/XML responses - Request/response size validation and security controls - Version headers and cache status reporting - Configuration hot-reloading and graceful error handling

The proxy works by intercepting HTTP responses, checking if they contain HTML or XML content that should be processed, parsing the content into a document tree, running configured plugins against the tree, and then serializing the modified content back to the response.

Example usage:

proxy, err := proxy.New(config, "v1.0.0")
if err != nil {
    log.Fatal(err)
}

http.ListenAndServe(":8080", proxy)

The proxy automatically adds X-XRP-Version and X-XRP-Cache headers to all responses to indicate processing status and enable monitoring.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ParserFunc

type ParserFunc func(body []byte) (interface{}, error)

ParserFunc defines a function that parses body bytes into a document

type ProcessorFunc

type ProcessorFunc func(plugin *plugins.LoadedPlugin, ctx context.Context, url *url.URL, document interface{}) error

ProcessorFunc defines a function that processes a document with a plugin

type Proxy

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

func New

func New(cfg *config.Config, version string) (*Proxy, error)

func (*Proxy) ServeHTTP

func (p *Proxy) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Proxy) UpdateConfig

func (p *Proxy) UpdateConfig(cfg *config.Config) error

type RendererFunc

type RendererFunc func(document interface{}) ([]byte, error)

RendererFunc defines a function that renders a document back to bytes

Jump to

Keyboard shortcuts

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