Baa 一个简单高效的Go web开发框架

网友投稿 702 2022-10-27

Baa 一个简单高效的Go web开发框架

Baa 一个简单高效的Go web开发框架

an express Go web framework with routing, middleware, dependency injection, http context.

Baa is no reflect, no regexp.

document

简体中文Englishgodoc

Getting Started

Install:

go get -u github.com/go-baa/baa

Example:

// baa.gopackage mainimport ( "github.com/go-baa/baa")func main() { app := baa.New() app.Get("/", func(c *baa.Context) { c.String(200, "Hello, 世界") }) app.Run(":1323")}

Build:

Baa use encoding/json as default json package but you can change to jsoniter by build from other tags

go build -tags=jsoniter .

Run:

go run baa.go

Explore:

http://127.0.0.1:1323/

Features

route support static, param, grouproute support handler chainroute support static file servemiddleware supoort handle chaindependency injection support*context support JSON/JSONP/XML/HTML responsecentralized HTTP error handlingcentralized log handlingwhichever template engine support(emplement baa.Renderer)

Examples

https://github.com/go-baa/example

blogapiwebsocket

Middlewares

gzipaccesslogrecoverysessionstaticrequestcachenocachejwtcorsauthz

Components

cacherenderpongo2routerpoolbatlogsetting

Performance

Route Test

Based on [go-http-routing-benchmark] (https://github.com/safeie/go-http-routing-benchmark), Feb 27, 2016.

GitHub API

Baa route test is very close to Echo.

BenchmarkBaa_GithubAll 30000 50984 ns/op 0 B/op 0 allocs/opBenchmarkBeego_GithubAll 3000 478556 ns/op 6496 B/op 203 allocs/opBenchmarkEcho_GithubAll 30000 47121 ns/op 0 B/op 0 allocs/opBenchmarkGin_GithubAll 30000 41004 ns/op 0 B/op 0 allocs/opBenchmarkGocraftWeb_GithubAll 3000 450709 ns/op 131656 B/op 1686 allocs/opBenchmarkGorillaMux_GithubAll 200 6591485 ns/op 154880 B/op 2469 allocs/opBenchmarkMacaron_GithubAll 2000 679559 ns/op 201140 B/op 1803 allocs/opBenchmarkMartini_GithubAll 300 5680389 ns/op 228216 B/op 2483 allocs/opBenchmarkRevel_GithubAll 1000 1413894 ns/op 337424 B/op 5512 allocs/op

HTTP Test

Code

Baa:

package mainimport ( "github.com/go-baa/baa")func main() { app := baa.New() app.Get("/", func(c *baa.Context) { c.String(200, "Hello, 世界") }) app.Run(":1323")}

Result:

$ wrk -t 10 -c 100 -d 30 http://127.0.0.1:1323/Running 30s test @ http://127.0.0.1:1323/ 10 threads and 100 connections Thread Stats Avg Stdev Max +/- Stdev Latency 1.64ms 299.23us 8.25ms 66.84% Req/Sec 6.11k 579.08 8.72k 68.74% 1827365 requests in 30.10s, 228.30MB readRequests/sec: 60704.90Transfer/sec: 7.58MB

Use Cases

vodjk private projects.

Credits

Get inspirations from beego echo macaron

safeie、micate - Authorbetty - Language ConsultantContributors

License

This project is under the MIT License (MIT) See the LICENSE file for the full license text.

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:非常轻量级的和简单的Go Web框架
下一篇:Microless是一个基于node.js koa的微服务框架
相关文章

 发表评论

暂时没有评论,来抢沙发吧~