https://github.com/queer/autumn
Experimental Netty-based Java 16 application/web framework
https://github.com/queer/autumn
Last synced: 11 months ago
JSON representation
Experimental Netty-based Java 16 application/web framework
- Host: GitHub
- URL: https://github.com/queer/autumn
- Owner: queer
- Created: 2021-05-01T20:40:14.000Z (about 5 years ago)
- Default Branch: mistress
- Last Pushed: 2023-03-06T15:57:18.000Z (over 3 years ago)
- Last Synced: 2023-03-06T17:16:49.074Z (over 3 years ago)
- Language: Java
- Homepage:
- Size: 356 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

Experimental Netty-based application/web framework.
An example application can be seen [here](https://github.com/queer/autumn/tree/mistress/autumn-example).
## Should I use this?
Probably not! It's still incredibly early-stage -- everything's versioned at
`0.0.1` for a reason, after all~ -- and so there's all sorts of instabilities,
weirdness, etc. that you probably don't want to deal with.
## Components
- `autumn-example`: Example application.
- `autumn-application`: Application bootstrap.
- `autumn-config`: [HJSON](https://hjson.github.io/)-based configuration.
- `autumn-di`: Dependency injection framework.
- `autumn-data`: Database access layer.
- `autumn-json`: JSON helper library.
- `autumn-web`: Web framework.
## What does work
- JVM boot to usable API in ~500ms
- Runs with 32MB of heap RAM or less
- Runtime DI + modularisation via components
- Component dependencies
- JSON
- Web server
- [HJSON](https://hjson.github.io/)-based autoconfig
- Object-mapping database manipulation via PostgreSQL JSONB.
## What doesn't work
- Multipart
- Websockets
- HTTP/2 (dealing with SSL is a hairy problem)
- Globbing routes
## Build an API in 30 seconds
```java
public class Readme {
public static void main(String[] args) {
AutumnApplication.run();
}
@Route(method = HttpMethod.GET, path = "/hello/:name")
public Response hello(Request req) {
return Response.create().body("henlo " + req.params().get("name") + '!');
}
}
```
## Modularise with components
```java
@Component
public class HelloComponent {
public String sayHello(String name) {
return "henlo " + name + "!";
}
}
public class Readme {
@Inject
private HelloComponent hello;
public static void main(String[] args) {
AutumnApplication.run();
}
@Route(method = HttpMethod.GET, path = "/hello/:name")
public Response hello(Request req) {
return Response.create().body(hello.sayHello(req.params().get("name")));
}
}
```
## Singleton components for ex. databases
```java
@Component
@Singleton
public class SingletonComponent {
public String sayHello(String name) {
return "henlo " + name + "!";
}
}
public class Readme {
@Inject
private SingletonComponent singleton;
public static void main(String[] args) {
AutumnApplication.run();
}
@Route(method = HttpMethod.GET, path = "/hello/:name")
public Response hello(Request req) {
return Response.create().body(singleton.sayHello(req.params().get("name")));
}
}
```