Skip to content

Commit

Permalink
Adds documentation for the architecture of Fuego and how to use it wi…
Browse files Browse the repository at this point in the history
…th Gin.
  • Loading branch information
EwenQuim committed Dec 24, 2024
1 parent 213c766 commit 73168e0
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
18 changes: 18 additions & 0 deletions documentation/docs/guides/alternative-routers-support/gin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Using Fuego with Gin

Fuego can be used with Gin by using the `fuegogin` adaptor.

Instead of using the **Server** (`fuego.NewServer()`), you will use the **Engine** (`fuego.NewEngine()`) along with your router.

The usage is similar to the default server, but you will need to declare the routes with `fuegogin.Get`, `fuegogin.Post`... instead of `fuego.Get`, `fuego.Post`...

## Migrate incrementally

1. Spawn an engine with `fuego.NewEngine()`.
2. Use `fuegogin.GetGin` instead of `gin.GET` to wrap the routes with OpenAPI declaration of the route, **without even touching the existing controllers**!!!
3. Replace the controllers **one by one** with Fuego controllers. You'll get complete OpenAPI documentation, validation, Content-Negotiation for each controller you replace!
4. Enjoy the benefits of Fuego with your existing Gin application!

## Example

Please refer to the [Gin example](https://github.com/go-fuego/fuego/tree/main/examples/gin-compat) for a complete and up-to-date example.
File renamed without changes.
13 changes: 13 additions & 0 deletions documentation/docs/internals/02-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Architecture

Fuego's architecture rely on the following components:

- **Engine**: The engine is responsible for handling the request and response. It is the core of Fuego.
- It contains the **OpenAPI** struct with the Description and OpenAPI-related utilities.
- It also contains the centralized Error Handler.
- **Server**: The default `net/http` server that Fuego uses to listen for incoming requests.
- Responsible for routes, groups and middlewares.
- **Adaptors**: If you use Gin, Echo, or any other web framework, you can use an adaptor to use Fuego with them.
- **Context**: The context is a generic typed interface that represents the state that the user can access & modify in the controller.

![Fuego Architecture](./architecture.png)
7 changes: 7 additions & 0 deletions documentation/docs/internals/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "⚙ Internals & Contributing",
"position": 4,
"link": {
"type": "generated-index"
}
}
Binary file added documentation/docs/internals/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 73168e0

Please sign in to comment.