Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.
/ gofury Public archive

fasthttp based api library inspired by dropwizard and utron

License

Notifications You must be signed in to change notification settings

gofury/gofury

Repository files navigation

GoFury

Build Status composable, open minded and light weight mvc library. Inspired dropwizard and utron. Usese fasthttp by default but can also switch to standard net/http in the future.

Features

  • Offer a set of reusable libraries similar to excellent gorilla libraries.
  • Designed to be 12factor compliant from the ground up
  • Both server and router are zero memory allocation and byte slice optimised
  • No lock in and non intrusive. Freely compatible with any fasthttp.RequestHandler based code or Middleware
  • Not opinionated about how you structure your business logic

Motivation

For a while I looked for a light weight go mvc library that was intuitive to use like Rails and dropwizard. The closest match I found was utron, which was impressive. But still suffers the same lock-in symptoms as more heavy weight web frameworks such as iris, gin or echo. Having an wrapper layer of utron.Ctx, iris.Context, gin.Context or echo.Context adds an extra layer of custom vendor complexity and straight away throws out any standard net/http or fasthttp compatible middlewares.

I wrote gofury to be a "library and not a "framework". It offers some opinions but does not enforce them. All libraries and interfaces can be replaced with alternatives to suit developer needs. Helpful but with zero lock-in.

func main() {
	app := gofury.BaseApplication{}

	// load configuration
	cfg := &gofury.HTTPConfig{}
	app.LoadConfig(cfg)

	// register services
	app.RegisterServices(createFastHTTPService(cfg, &log.Logger{}), createQueueService())

	// start up application
	app.StartUp()

	// shudown cleanly when application exits
	defer app.ShutDown()
}

Friends

GoFury out of the box forms a composition glue between the following libraries:

  • fasthttp zero mem alloc http server, sensible RequestCtx that is easy to use and test
  • fasthttprouter zero mem alloc router
  • fusion middleware chaining inspired by alice
  • envconfig environment variable based config
  • apex/log simple, handler based structured logging
  • glide for depedency management that makes sense

Testing is made easier with:

Other options libraries:

Build

make test

Sample Project

See examples/example_test.go

Todo

  • db migration
  • metrics and healthcheck
  • standard net/http module