rockgo

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2020 License: MIT

README

RockGo Application Framework

RockGo is fast, simple application framework for Go.

RockGo is agent to iris, fluentd, statsd, zap and sentry too. It make easy to build perfect application or service.

Features

  • Application
    • Service, ServiceGroup
    • Config
    • Basic middleware
      • Access log
      • recover & metric
    • Logger integration
    • Metric (Stats)
    • Sentry
  • Log
    • Logger, Output, Format
    • zap
    • fluent
  • Crypto
    • AES
    • Digest (MD5, SHA1/256/512)
    • RSA
  • Example
    • Route - Application, Config
    • Metric & Sentry

Example

Please visit example.

Install

  • go get
$ go get github.com/byte-power/rockgo
  • Add import
import "github.com/byte-power/rockgo/rock"
  • Add config file named "rockgo.yaml" for internal modules on your settings directory
app_name: myapp
log:
  LoggerName:
    console:
    fluent:
      level: info
      host: "myfluenthost.com"
      port: 24224
      async: true
metric:
  host: "127.0.0.1:8125"
sentry:
  dsn: "http://user@127.0.0.1/1"
  repanic: true
  • Append routes, middlewares and then Run server
func main() {
  // load each config file include rockgo.yaml in the directory to create Application
  app, err := rock.NewApplication("settings")
  if err != nil {
    panic(err)
  }
  // register route handler with Service
  app.Serve("root", "/").Get(func(ctx iris.Context) {
    ctx.StatusCode(http.StatusOK)
    ctx.Text("Hello RockGo")
  })
  groupArt := app.ServeGroup("article", "/arts")
  groupArt.Use(/* append middleware working on the group only, e.g. authentication */)
  groupArt.Serve("root", "/").Get(func(ctx iris.Context) {
    // do something to response /arts/
  })
  err = app.Run(":8080")
  if err != nil {
    panic(err)
  }
}

License

MIT

Directories

Path Synopsis
middlewares

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL