Skip to content

Latest commit

 

History

History
42 lines (36 loc) · 2.03 KB

README.md

File metadata and controls

42 lines (36 loc) · 2.03 KB

Middlewares

Middlewares and helper modules allow you easily plugin/unplugin features for your Macaron applications.

There are already many middlewares and modules to simplify your work:

  • auth - HTTP Basic authentication
  • authz - ACL, RBAC and ABAC authorization based on Casbin
  • bindata - Embed binary data as static and template files
  • binding - Request data binding and validation
  • cache - Cache manager
  • captcha - Captcha service
  • csrf - Generates and validates CSRF tokens
  • gzip - Gzip compression to all responses
  • i18n - Internationalization and Localization
  • inject - Map and inject dependencies
  • jade - Jade templating engine
  • method - HTTP method override
  • oauth2 - OAuth 2.0 backend client
  • permissions2 - Cookies, users and permissions
  • pongo2 - Pongo2 template engine support
  • renders - Beego-like render engine (Macaron has built-in template engine, this is another option)
  • session - Session manager
  • sockets - WebSockets channels binding
  • switcher - Multiple-site support
  • toolbox - Health check, pprof, profile and statistic services

Best register order for middlewares

Some middlewares depends on others, here is a list for best ordering:

  1. macaron.Logger()
  2. macaron.Recovery()
  3. gzip.Gziper()
  4. macaron.Static()
  5. macaron.Renderer()/pongo2.Pongoer()
  6. i18n.I18n()
  7. cache.Cacher()
  8. captcha.Captchaer()
  9. session.Sessioner()
  10. csrf.Csrfer()
  11. toolbox.Toolboxer()