百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

fuego

> 编程语言
开源

Golang Fuego - 从源代码生成 OpenAPI 3 规范的 Web 框架 - 可与现有的 Gin 和 Echo API 进行插件化

1.8K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

Golang Fuego - 从源代码生成 OpenAPI 3 规范的 Web 框架 - 可与现有的 Gin 和 Echo API 进行插件化

# Fuego > The framework for busy Go developers **Explore and contribute to our [2025 Roadmap](https://github.com/go-fuego/fuego/discussions/263)!** Production-ready Go API framework generating OpenAPI documentation from code. Inspired by Nest, built for Go developers. Also empowers templating with `html/template`, `a-h/templ` and `maragudk/gomponents`: see [the example](./examples/full-app-gourmet) [running live](https://gourmet.quimerch.com). ## Why Fuego? Chi, Gin, Fiber and Echo are great frameworks. But since they were designed a long time ago, [their current API does not allow them][gin-gonic-issue] to deduce OpenAPI types from signatures, things that are now possible with generics. Fuego offers a lot of "modern Go based" features that make it easy to develop APIs and web applications. ## Features - **OpenAPI**: Fuego automatically generates OpenAPI documentation from **code** - _not from comments nor YAML files!_ - **100% `net/http` compatible** (no lock-in): Fuego is built on top of `net/http`, so you can use any `http.Handler` middleware or handler! Fuego also supports `log/slog`, `context` and `html/template`. - **Routing**: Fuego router is based on Go 1.22 `net/http`, with grouping and middleware support - **Serialization/Deserialization**: Fuego automatically serializes and deserializes JSON, XML and HTML Forms based on user-provided structs (or not, if you want to do it yourself) - **Validation**: Fuego provides a simple and fast validator based on `go-playground/validator` - **Transformation**: easily transform your data by implementing the `fuego.InTransform` and `fuego.OutTransform` interfaces - also useful for custom **validation** - **Middlewares**: easily add a custom `net/http` middleware or use the provided middlewares. - **Error handling**: Fuego provides centralized error handling with the standard [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457). - **Rendering**: Fuego provides a simple and fast rendering system based on `html/template` - you can still also use your own template system like `templ` or `gomponents` - **Adaptors**: Fuego can be plugged to an existing Gin or Echo server to generate OpenAPI documentation ## Examples ### Hello World ```go package main import "github.com/go-fuego/fuego" func main() { s := fuego.NewServer() fuego.Get(s, "/", func(c fuego.ContextNoBody) (string, error) { return "Hello, World!", nil }) s.Run() } ``` ### Simple POST ```go package main import "github.com/go-fuego/fuego" type MyInput struct { Name string `json:"name" validate:"required"` } type MyOutput struct { Message string `json:"message"` } func main() { s := fuego.NewServer() // Automatically generates OpenAPI documentation for this route fuego.Post(s, "/user/{user}", myController) s.Run() } func myController(c fuego.ContextWithBody[MyInput]) (*MyOutput, error) { body, err := c.Body() if err != nil { return nil, err } return &MyOutput{Message: "Hello, " + body.Name}, nil } ``` ### With transformation & custom validation ```go type MyInput struct { Name string `json:"name" validate:"required"` } // Will be called just before returning c.Body() func (r *MyInput) InTransform(context.Context) error { r.Name = strings.ToLower(r.Name) if r.Name == "fuego" { return errors.New("fuego is not a valid name for this input") } return nil } ``` ### More OpenAPI documentation ``` … ``` ### Std lib compatibility ```go package main import ( "net/http" "github.com/go-fuego/fuego" ) func main() { s := fuego.NewServer() // Standard net/http middleware fuego.Use(s, func(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("X-Hello", "World") next.ServeHTTP(w, r) }) }) // Standard net/http handler with automatic OpenAPI route declaration fuego.GetStd(s, "/std", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello, World!")) }) s.Run() } ``` ### Real-world examples Please see the [`/examples` folder](./examples/) for more examples. - [Simple CRUD with OpenAPI](./examples/petstore) - [Full app with HTML rendering](./examples/full-app-gourmet) All features ``` … ``` ```bash curl http://localhost:8088/std # Hello, World! curl http://localhost:8088 -X POST -d '{"name": "Your Name"}' -H 'Content-Type: application/json' # {"message":"HELLO, YOUR NAME","best":"Fuego!"} curl http://localhost:8088 -X POST -d '{"name": "Fuego"}' -H 'Content-Type: application/json' # {"error":"cannot transform request body: cannot transform request body: fuego is not a name"} ``` ## From net/http to Fuego in 10s Views ### Before #### After #### Diff #### Benefits of using Fuego views (controllers returning HTML) - Never forget to return after an error - OpenAPI schema generated, listing all the routes - Deserialization and validation are easier - Transition to Fuego is easy and fast ## Contributing See the [contributing guide](CONTRIBUTING.md). Thanks to [everyone who has contributed][contributors-url] to this project! ❤️ Made with [contrib.rocks](https://contrib.rocks) ## Roadmap See the [board](https://github.com/orgs/go-fuego/projects/1). ## Disclaimer for experienced gophers I know you might prefer to use `net/http` directly, but if having a frame can convince my company to use Go instead of Node, I'm happy to use it. ## License [MIT](./LICENSE.txt) [gin-gonic-issue]: https://github.com/gin-gonic/gin/issues/155 [contributors-url]: https://github.com/go-fuego/fuego/graphs/contributors

GitHub Issues· 0 开放

在 GitHub 查看全部

暂无开放 Issues,或尚未同步最近议题。

核心特点

  • •OpenAPI: Fuego automatically generates OpenAPI documentation
  • •100% net/http compatible (no lock-in): Fuego is built on top of net/http,
  • •Routing: Fuego router is based on Go 1.22 net/http, with grouping and
  • •Serialization/Deserialization: Fuego automatically serializes and
  • •Validation: Fuego provides a simple and fast validator based on go-playground/validator
  • •Transformation: easily transform your data by implementing the
  • •Middlewares: easily add a custom net/http middleware
  • •Error handling: Fuego provides centralized error handling with
  • •Rendering: Fuego provides a simple and fast rendering system based on
  • •Adaptors: Fuego can be plugged to an existing Gin or Echo server to

> 标签

Goechofuegogin-gonicgolang

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言