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

PreviousCustom ServicesNextRouting

Last updated 5 years ago

Was this helpful?

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

There are already many to simplify your work:

  • - HTTP Basic authentication

  • - ACL, RBAC and ABAC authorization based on

  • - Embed binary data as static and template files

  • - Request data binding and validation

  • - Cache manager

  • - Captcha service

  • - Generates and validates CSRF tokens

  • - Gzip compression to all responses

  • - Internationalization and Localization

  • - Map and inject dependencies

  • - Jade templating engine

  • - HTTP method override

  • - OAuth 2.0 backend client

  • - Cookies, users and permissions

  • - Pongo2 template engine support

  • - Beego-like render engine (Macaron has built-in template engine, this is another option)

  • - Session manager

  • - WebSockets channels binding

  • - Multiple-site support

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

middlewares and modules
auth
authz
Casbin
bindata
binding
cache
captcha
csrf
gzip
i18n
inject
jade
method
oauth2
permissions2
pongo2
renders
session
sockets
switcher
toolbox