top

Package ab is the main package of the Alien Bunny web development kit.

This package contains the server and the middlewares of the framework. If you want to get started, you probably want to take a look at Hop and PetBunny.

The lowest level component is the Server component. It is a wrapper on the top of httprouter that adds middlewares along with a few useful features. On the server you can configure Services. Services are logical units of endpoints that share a piece of schema. On the top of the services, there are resources. Resources are CRUD endpoints. There are delegates and event handlers that help augmenting the functionality of the ResourceController.

Entities are a pointer to a struct that can be stored in a database. EntityController automatically does CRUD on entities, and the operations can be customized with delegates and event handlers.

EntityResource combines the EntityController and the ResourceController to easily expose an entity through API endpoints.

Quick and dirty usage:

func main() {
	ab.Hop(func(cfg *viper.Viper, s *ab.Server) error {
		ec := ab.NewEntityController(s.GetDBConnection())
		ec.Add(&Content{}, contentEntityDelegate{})

		res := ab.EntityResource(ec, &Content{}, ab.EntityResourceConfig{
			DisableList: true,
			DisablePost: true,
			DisablePut: true,
			DisableDelete: true,
		})

		s.RegisterService(res)

		return nil
	}, nil)
}

Imported by 4 package(s)

  1. github.com/Pronovix/walkhub-service
  2. gitlab.com/tamasd/ab/providers/auth/google
  3. gitlab.com/tamasd/ab/services/auth
  4. gitlab.com/tamasd/ab/services/search

Imports 11 package(s)

  1. github.com/spf13/viper
  2. gitlab.com/tamasd/ab/lib/log
  3. github.com/golang/gddo/httputil
  4. github.com/julienschmidt/httprouter
  5. golang.org/x/crypto/acme/autocert
  6. github.com/NYTimes/gziphandler
  7. github.com/lib/pq
  8. github.com/smartystreets/goconvey/convey
  9. github.com/agtorre/gocolorize
  10. golang.org/x/crypto/acme
  11. gitlab.com/tamasd/ab/util

Test imports 1 package(s)

  1. golang.org/x/net/publicsuffix