Macaron Documentation
  • Welcome
  • Starter Guide
  • Core Concepts
  • Core Services
  • Custom Services
  • Middlewares
    • Routing
    • Templating
    • Gzip
    • Localization
    • Data Binding and Validation
    • Cache
    • Captcha
    • Session
    • Cross-Site Request Forgery
    • Embed Binary Data
    • Serving Multiple Sites
  • FAQs
  • 简体中文
    • 初学者指南
    • 核心概念
    • 核心服务
    • 自定义服务
    • 中间件和辅助模块
      • 路由模块
      • 模板引擎
      • Gzip 压缩
      • 应用本地化
      • 数据绑定与验证
      • 缓存管理(Cache)
      • 验证码服务
      • 会话管理(Session)
      • 跨域请求攻击(CSRF)
      • 嵌入二进制数据
      • 服务多个站点
    • 常见问题
Powered by GitBook
On this page

Was this helpful?

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()

PreviousCustom ServicesNextRouting

Last updated 5 years ago

Was this helpful?