Skip to content

jamesaduncan/rusty-beam

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Rusty Beam

A high-performance HTTP server with unique CSS selector-based HTML manipulation capabilities, plugin architecture, and built-in authentication/authorization.

License Rust Documentation

Overview

Rusty Beam is an experimental HTTP server that extends standard REST operations with CSS selector support, allowing you to manipulate HTML documents through simple HTTP requests. Built on high-performance async Rust with hyper and tokio, it provides a unique approach to dynamic content management.

✨ Key Features

Core Capabilities

  • 🎯 CSS Selector API: Manipulate HTML using standard CSS selectors via HTTP Range headers
  • πŸ”Œ Plugin Architecture: Extensible system with authentication, compression, CORS, and more
  • ⚑ High Performance: Async Rust with zero-copy operations and efficient concurrency
  • πŸ”’ Built-in Security: Authentication, authorization, rate limiting, and security headers
  • πŸ“ HTML Configuration: Human-readable configuration using HTML with microdata
  • πŸ”„ Hot Reload: Update configuration without restarting via SIGHUP

Standard File Operations

  • GET: Serve files with automatic index.html serving
  • PUT: Upload or replace files (201 for new, 200 for updates)
  • POST: Append to files or create in directories
  • DELETE: Remove files or empty directories

HTML Manipulation via CSS Selectors

  • GET + Selector: Extract specific elements (returns 206 Partial Content)
  • PUT + Selector: Replace elements (returns 206 with updated element)
  • POST + Selector: Append to elements (returns 206 with updated element)
  • DELETE + Selector: Remove elements (returns 204 No Content)

πŸš€ Quick Start

Installation

# Clone the repository
git clone https://github.com/jamesaduncan/rusty-beam.git
cd rusty-beam

# Build the server and plugins
cargo build --release
./build-plugins.sh

# Run with example configuration
./target/release/rusty-beam config/config.html

Docker Quick Start

# Using Docker
docker pull rustybeam/rusty-beam:latest
docker run -p 3000:3000 -v ./config:/etc/rusty-beam rustybeam/rusty-beam

# Using Docker Compose
docker-compose up -d

See the Installation Guide for detailed instructions.

πŸ› οΈ Usage Examples

Basic Configuration

Create a simple configuration file config.html:

<!DOCTYPE html>
<html>
<body>
    <table itemscope itemtype="http://rustybeam.net/ServerConfig">
        <tr><td itemprop="bind">127.0.0.1</td></tr>
        <tr><td itemprop="port">3000</td></tr>
        <tr><td itemprop="root">./public</td></tr>
    </table>
    
    <ul>
        <li itemscope itemtype="http://rustybeam.net/HostConfig">
            <span itemprop="host">*</span>
            <ul>
                <li itemprop="plugin" itemscope itemtype="http://rustybeam.net/Plugin">
                    <span itemprop="library">file://./plugins/lib/selector-handler.so</span>
                </li>
                <li itemprop="plugin" itemscope itemtype="http://rustybeam.net/Plugin">
                    <span itemprop="library">file://./plugins/lib/file-handler.so</span>
                </li>
            </ul>
        </li>
    </ul>
</body>
</html>

Basic File Operations

# Upload an HTML file
curl -X PUT -d '<html><body><h1 id="title">Hello</h1><p class="content">World</p></body></html>' \
  http://localhost:3000/test.html
# Response: 201 Created

# Retrieve the file
curl http://localhost:3000/test.html
# Response: 200 OK (full document)

CSS Selector Operations

# Extract specific element
curl -H "Range: selector=#title" http://localhost:3000/test.html
# Response: 206 Partial Content
# Body: <h1 id="title">Hello</h1>

# Replace element
curl -X PUT -H "Range: selector=#title" \
  -d '<h1 id="title">Updated Title</h1>' \
  http://localhost:3000/test.html
# Response: 206 Partial Content
# Body: <h1 id="title">Updated Title</h1>

# Append to element
curl -X POST -H "Range: selector=body" \
  -d '<footer>Copyright 2024</footer>' \
  http://localhost:3000/test.html
# Response: 206 Partial Content
# Body: (body element with appended footer)

# Remove element
curl -X DELETE -H "Range: selector=.old-content" \
  http://localhost:3000/test.html
# Response: 204 No Content

πŸ”Œ Plugin System

Rusty Beam features a powerful plugin architecture. Available plugins include:

Core Plugins

  • selector-handler - CSS selector operations for HTML manipulation
  • file-handler - Static file serving with directory index support
  • basic-auth - HTTP Basic Authentication with bcrypt support
  • authorization - Role-based access control (RBAC)
  • access-log - Request logging in Apache/Combined format

Additional Plugins

  • compression - Gzip/deflate compression for responses
  • cors - Cross-Origin Resource Sharing configuration
  • security-headers - Security headers (HSTS, CSP, etc.)
  • rate-limit - Token bucket rate limiting
  • redirect - URL redirection with pattern matching
  • cache-control - HTTP caching headers
  • error-handler - Custom error pages
  • websocket - WebSocket support for real-time updates
  • health-check - Health monitoring endpoints

See the Plugin Documentation for configuration details.

πŸ“š Documentation

Guides

Reference

Examples

πŸ§ͺ Development

Building from Source

# Clone and build
git clone https://github.com/jamesaduncan/rusty-beam.git
cd rusty-beam
cargo build --release
./build-plugins.sh

# Run tests
./run_all_tests.sh

# Run with verbose logging
cargo run -- -v config/config.html

Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • Code standards
  • Development workflow
  • Testing requirements
  • Pull request process

Project Structure

rusty-beam/
β”œβ”€β”€ src/              # Core server code
β”œβ”€β”€ plugins/          # Plugin implementations
β”œβ”€β”€ tests/            # Test suites
β”œβ”€β”€ docs/             # Documentation
β”œβ”€β”€ examples/         # Example configurations
└── config/           # Default configuration

πŸš€ Performance

Rusty Beam is designed for high performance:

  • Concurrent Connections: 10,000+ simultaneous connections
  • Throughput: 50,000+ requests/second (small files)
  • Latency: < 1ms for cached static files
  • Memory Usage: ~50MB base + content cache

See the Performance Guide for optimization tips.

πŸ”’ Security

Security features include:

  • Path traversal protection
  • Configurable authentication and authorization
  • Rate limiting and DDoS protection
  • Security headers (HSTS, CSP, X-Frame-Options, etc.)
  • Input validation for CSS selectors

See the Security Guide for best practices.

🌟 Use Cases

Rusty Beam is ideal for:

  • Dynamic Websites: Update content without regenerating pages
  • Content Management: Direct HTML manipulation via API
  • API Gateways: Proxy with authentication and rate limiting
  • Static Site Enhancement: Add dynamic features to static sites
  • Development Tools: Rapid prototyping with live updates
  • Microservices: Lightweight service with plugin architecture

🀝 Community

πŸ“œ License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.

πŸ™ Acknowledgments

Built with:

  • Hyper - Fast HTTP implementation
  • Tokio - Async runtime
  • dom_query - HTML parsing and manipulation

Note: This is experimental software. While it's designed for production use, please test thoroughly in your environment before deploying to production.

About

A rusty old beam

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •