Thank you for your interest in contributing to HTTP-ME! This document provides guidelines and information to help you contribute effectively.
- Rust (version 1.83.0 or later)
- Fastly CLI
- Git
-
Clone the repository:
git clone https://github.com/BrooksCunningham/http-me-rust.git cd http-me-rust -
Install Rust and add WASM target:
rustup target add wasm32-wasip1
-
Install Fastly CLI: Follow the Fastly CLI installation guide
Build the project using Cargo:
cargo buildFor Fastly Compute@Edge builds:
fastly compute buildTo run the service locally using Fastly's local development server:
fastly compute serveThe service will be available at http://localhost:7676
Once the local server is running, you can test endpoints:
# Test status endpoint
curl -i http://localhost:7676/status/404
# Test anything endpoint
curl http://localhost:7676/anything/test?foo=bar
# Test with custom headers
curl -H 'endpoint:status=302' http://localhost:7676/testWe use Clippy for linting. Run it before submitting changes:
cargo clippy -- -W clippy::allAll clippy warnings should be addressed.
Use rustfmt to format your code:
cargo fmt- Documentation: Add doc comments (
///) for all public functions and modules - Constants: Use named constants instead of magic strings or numbers
- Error Handling: Properly handle and propagate errors using
Result<T, Error> - CORS: Ensure endpoints that need CORS support include appropriate headers
- Performance: Be mindful of allocations and cloning in hot paths
http-me-rust/
├── src/
│ └── main.rs # Main application code with all endpoint handlers
├── static-assets/ # Static files served via KV store
│ ├── swagger.html # Swagger UI
│ ├── openapi-spec.json # OpenAPI specification
│ └── ... # Other static assets
├── fastly.toml # Fastly service configuration
├── Cargo.toml # Rust dependencies
└── README.md # Project documentation
When adding a new endpoint:
- Define constants at the top of
main.rsfor any new paths, headers, or configuration values - Create a handler function with proper documentation:
/// Brief description of what the endpoint does. /// /// # Arguments /// /// * `req` - The incoming HTTP request /// * `resp` - The response object to populate /// /// # Returns /// /// Description of what is returned /// /// # Errors /// /// Description of possible errors fn my_endpoint(req: Request, mut resp: Response) -> Result<Response, Error> { // Implementation }
- Add routing in the
handler()function - Update documentation including README.md and OpenAPI spec if applicable
- Test the endpoint locally before submitting
Static assets are stored in the static-assets/ directory and served via Fastly's KV Store.
To add new static assets:
- Add the file to
static-assets/ - Update
fastly.tomlto include the new file in thelocal_server.kv_storessection - For production, the GitHub Actions workflow will update the KV store automatically
The API is documented using OpenAPI 3.0. The specification is located at static-assets/openapi-spec.json.
When adding or modifying endpoints, update the OpenAPI spec accordingly.
Currently, the project focuses on manual testing using the local Fastly server. Future contributions to add automated testing are welcome.
When making changes, test:
- All affected endpoints work correctly
- Error cases are handled properly
- CORS headers are present where needed
- Status codes are appropriate
- Response formats match the OpenAPI spec
-
Create a branch for your changes:
git checkout -b feature/your-feature-name
-
Make your changes following the code standards above
-
Test your changes locally using
fastly compute serve -
Commit your changes with clear, descriptive commit messages:
git commit -m "Add feature: description of what you added" -
Push your branch:
git push origin feature/your-feature-name
-
Create a Pull Request on GitHub with:
- A clear title describing the change
- A description of what changed and why
- Any testing you performed
- References to related issues
The project uses GitHub Actions for continuous integration and deployment:
- Test & Build: On every push, the code is built and tested
- Deploy: On pushes to
main, the service is deployed to Fastly Compute@Edge - WAF Testing: Tests include Next-Gen WAF (NGWAF) integration tests
cargo updateCheck for outdated dependencies:
cargo outdated-
Add to
Cargo.toml:[dependencies] new-crate = "1.0"
-
Run
cargo buildto fetch and build the dependency
- Issues: Open an issue on GitHub for bugs or feature requests
- Discussions: Use GitHub Discussions for questions
- Security: See SECURITY.md for reporting security issues
- Be respectful and inclusive
- Focus on constructive feedback
- Help create a welcoming environment for all contributors
By contributing to HTTP-ME, you agree that your contributions will be licensed under the MIT License.
Thank you for contributing to HTTP-ME! 🚀