Skip to content

Commit

Permalink
Merge pull request #58 from Basicprogrammer10/dev
Browse files Browse the repository at this point in the history
Alpha release 3 for `v3.0.0`
  • Loading branch information
connorslade authored Feb 5, 2024
2 parents 07c27ae + 958a3bd commit c2c47a5
Show file tree
Hide file tree
Showing 75 changed files with 2,960 additions and 807 deletions.
7 changes: 7 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./examples/basic/Cargo.toml",
"./examples/paste_bin/Cargo.toml"
]
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
authors = ["Connor Slade <connor@connorcode.com>"]
edition = "2018"
name = "afire"
version = "3.0.0-alpha.2"
version = "3.0.0-alpha.3"

categories = ["network-programming", "web-programming::http-server"]
description = "🔥 A blazing fast web framework for Rust"
documentation = "https://docs.rs/afire"
exclude = [".github/", "SocialShare.*", ".devcontainer"]
exclude = [".github", ".devcontainer", ".vscode", "SocialShare.*"]
homepage = "https://connorcode.com/writing/afire"
keywords = ["afire", "http", "WebFramework", "WebServer"]
license = "MIT"
Expand Down
18 changes: 17 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@ Coming Soon
- Rename HeaderType to HeaderName as that is the correct name.
- Accept `Into<Header>` in `Context::header` and `Response::header`.
- Create 'header structs' that can be converted into a `Header` and simplify working with headers in responses.
- Use [loopback](https://tools.ietf.org/html/rfc1122), [private](https://tools.ietf.org/html/rfc1918), and [unique local](https://tools.ietf.org/html/rfc4193) addresses for RealIp
- Add is_informational, is_success, is_redirect, is_client_error, and is_server_error methods on status codes.
- Use a Cow in HeaderName::Custom
- Don't store whole stream to get its length in Head ext
- Added sync_route extension
- Make threadpool more robust
- Add a Stream trait to allow using different socket impls
- Allow using custom event loop
- The custom event loop with the Stream trait should allow a separate crate to add tls support to an afire server
- Cleanup Query struct
- Now stores a set of QueryParameter structs instead of [String; 2]
- Implement Debug for Query
- Rename `Query::from_body` to `Query::from_str`
- Made internal::handle::handle function public for use in custom event loops.
- Made `error::AnyResult` public
- Disable keep-alive if only running with one thread

# 2.2.1

Expand Down Expand Up @@ -201,7 +217,7 @@ Apr 10, 2022
- Add SocketHandler struct to hold socket interacting functions
- Fix Path Traversal Exploit O_O

# 1.0.0!
# 1.0.0

Mar 14, 2022

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Connor Slade
Copyright (c) Connor Slade

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Just add the following to your `Cargo.toml`:

```toml
[dependencies]
afire = "3.0.0-alpha.2"
afire = "3.0.0-alpha.3"
```

## 📄 Info
Expand All @@ -32,13 +32,10 @@ For more examples see the examples directory [here](https://github.com/Basicprog
Below is a super simple example so you can see the basics of afire syntax.

```rust no_run
// Import Lib
use afire::{Server, Method, Response, Header, Content};
use afire::prelude::*;

// Create Server
let mut server = Server::<()>::new("localhost", 8080);

// Add a route
server.route(Method::GET, "/greet/{name}", |ctx| {
let name = ctx.param("name");

Expand All @@ -49,7 +46,6 @@ server.route(Method::GET, "/greet/{name}", |ctx| {
Ok(())
});

// Start the server
server.run().unwrap();
```

Expand Down
43 changes: 13 additions & 30 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,21 @@

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=394493528&machine=basicLinux32gb&location=EastUs&devcontainer_path=.devcontainer%2Fdevcontainer.json)

## Basic
## Applications

Basic examples give you a nice and simple first look into using afire.
Run `cargo r --example basic` to use the example picker menu thing.
You can also run a specific example with `cargo r --example basic -- <EXAMPLE_NAME>`.
The source code for each basic example can be found within the `basic` subdirectory in a file with the same name as the example.
### [Basic](basic)

| Name | Description |
| ------------------------------ | ---------------------------------------------------------------------- |
| basic | Start a basic web server that serves static text. |
| serve_file | Serve a file from the local file system. |
| routing | Learn about routing priority and create a 404 page |
| data | Send data to server with a Query String, Path parameters and Form Data |
| header | Make and Read Headers to send extra data |
| path_param | Use path parameters on a route |
| state | Add a server-wide state and use stateful routes |
| cookie | Read and Write cookies to the client |
| error_handling | Catch panics in routes and middleware |
| serve_static | Staticky serve a whole directory |
| middleware (show state access) | Use Middleware to log requests and modify responses |
| logging | Log requests to a file or console |
| rate_limit | Add a rate limit to your server |
| threading | Use a thread pool to handle requests |
| trace | Use afire's built-in logging system |
Shows the very basics of afire:

## Application
- Creating routes
- Creating and using Middleware
- Server state
- Accepting JSON requests
- Accepting
- Responding with JSOn

These are more complete examples, still not a full web app through.
For more complete web apps you can reference the [Things Built with afire](https://connorcode.com/writing/afire#things-built-with-afire) section on my website.
To run these application examples you can use this command `cargo r --example application_<EXAMPLE_NAME>`.
### [Pastebin](paste_bin)

| Name | Description |
| ---------- | --------------------------------------------------- |
| paste_bin | A very simple in memory paste bin system |
| quote_book | A delightfully 90s website to store and view quotes |
A simple pastebin, but a more complete example.
Shows how to use a database, render templates, create api routes, accept form data, handle shutdowns, and more.
I have actually made a real pastebin with afire ([plaster-box](https://github.com/Basicprogrammer10/plaster-box)), but because I started on it so long ago I prefer some of the practices used in this example.
167 changes: 167 additions & 0 deletions examples/basic/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions examples/basic/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "basic"
version = "0.1.0"
edition = "2021"

[dependencies]
afire = { path = "../..", features = ["extensions"] }
anyhow = "1.0.75"
rand = "0.8.5"
serde = { version = "1.0.188", features = ["derive"] }
serde_json = "1.0.107"
Loading

0 comments on commit c2c47a5

Please sign in to comment.