byom gateway to redirect customer to their own vps
![]() |
1 月之前 | |
---|---|---|
app | 1 月之前 | |
config | 1 月之前 | |
errors | 1 月之前 | |
handlers | 1 月之前 | |
logger | 1 月之前 | |
middleware | 1 月之前 | |
store | 1 月之前 | |
.dockerignore | 1 月之前 | |
.gitignore | 1 月之前 | |
Dockerfile | 1 月之前 | |
README.md | 1 月之前 | |
config.sample.yaml | 1 月之前 | |
go.mod | 1 月之前 | |
go.sum | 1 月之前 | |
main.go | 1 月之前 | |
test.json | 1 月之前 |
I'll help you add documentation by creating a README.md file and adding some package-level documentation. Let's start with the main README:
# BYOM Gateway
BYOM Gateway is a Go-based service that manages user-host associations with a secure REST API.
## Features
- RESTful API for user-host management
- SQLite database with WAL mode for data persistence
- Secure by default with comprehensive security middleware
- Structured logging and request tracing
- Configuration via YAML
- Basic authentication support
## Prerequisites
- Go 1.19 or higher
- SQLite 3
## Quick Start
1. Clone the repository:
bash git clone git.linuxforward.com/byom/byom-gateway cd byom-gateway
2. Copy the sample config:
bash cp config.sample.yaml config.yaml
3. Build and run:
bash go build ./byom-gateway
## Configuration
Configuration is managed through a YAML file. Example configuration:
yaml server: port: "8080" tls:
enabled: false
cert: ""
key: ""
database: file: "./data/dev.db" log_mode: true max_open_conns: 10 max_idle_conns: 5 conn_max_lifetime: 3600 pragma:
- "journal_mode=WAL"
- "busy_timeout=5000"
- "foreign_keys=ON"
basic_auth: username: "admin" password: "your_secure_password"
## API Documentation
### User-Host Management
#### Get User Host
http GET /api/v1/user-host?email=user@example.com
Response:
json {
"email": "user@example.com",
"host": "host.example.com"
}
#### Add User Host
http POST /api/v1/user-host
Request body:
json {
"email": "user@example.com",
"host": "host.example.com"
}
## Security
The service implements several security measures:
- CORS protection
- Security headers (HSTS, CSP, etc.)
- Request sanitization
- Basic authentication
- TLS support
- Request rate limiting
## Development
### Project Structure
. ├── app/ # Application initialization and setup ├── config/ # Configuration handling ├── errors/ # Custom error types ├── handlers/ # HTTP request handlers ├── logger/ # Logging configuration ├── middleware/ # HTTP middleware ├── store/ # Database operations └── main.go # Application entry point ```
store/
handlers/
app/app.go
[License details here]