11 Star 36 Fork 3

Baa / Baa

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

Baa GoDoc License Build Status Coverage Status

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

Baa is no reflect, no regexp.

document

Getting Started

Install:

go get -u gopkg.in/baa.v1

Example:

// baa.go
package main

import (
    "gopkg.in/baa.v1"
)

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, group
  • route support handler chain
  • route support static file serve
  • middleware supoort handle chain
  • dependency injection support*
  • context support JSON/JSONP/XML/HTML response
  • centralized HTTP error handling
  • centralized log handling
  • whichever template engine support(emplement baa.Renderer)

Examples

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

Middlewares

Components

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/op
BenchmarkBeego_GithubAll        	    3000	    478556 ns/op	    6496 B/op	     203 allocs/op
BenchmarkEcho_GithubAll         	   30000	     47121 ns/op	       0 B/op	       0 allocs/op
BenchmarkGin_GithubAll          	   30000	     41004 ns/op	       0 B/op	       0 allocs/op
BenchmarkGocraftWeb_GithubAll   	    3000	    450709 ns/op	  131656 B/op	    1686 allocs/op
BenchmarkGorillaMux_GithubAll   	     200	   6591485 ns/op	  154880 B/op	    2469 allocs/op
BenchmarkMacaron_GithubAll      	    2000	    679559 ns/op	  201140 B/op	    1803 allocs/op
BenchmarkMartini_GithubAll      	     300	   5680389 ns/op	  228216 B/op	    2483 allocs/op
BenchmarkRevel_GithubAll        	    1000	   1413894 ns/op	  337424 B/op	    5512 allocs/op

HTTP Test

Code

Baa:

package main

import (
	"gopkg.in/baa.v1"
)

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 read
Requests/sec:  60704.90
Transfer/sec:      7.58MB

Use Cases

vodjk private projects.

Credits

Get inspirations from beego echo macaron

License

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

Comments ( 0 )

Sign in for post a comment

About

一个简单高效的Go web开发框架。主要有路由、中间件,依赖注入和HTTP上下文构成。 spread retract
Go and 2 more languages
MIT
Cancel

Releases

No release

Gitee Metrics

Contributors

All

Activities

load more
can not load any more
Go
1
https://git.oschina.net/go-baa/baa.git
git@git.oschina.net:go-baa/baa.git
go-baa
baa
Baa
master

Search