middleware/

directory
v0.0.0-...-59f5a4e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2020 License: MIT

README

middleware

Here we learn how to operate 3 kinds of middleware in server.

global-middleware

All handler will pass through.

srv.UseGlobal(middleware)

anchor-middleware

using Use and UnUse to seperate routers. In handlers below, middleware1 will make effect on handler, handler3

srv.Use("middleware-key", middleware)
srv.AddHandler(messageID, handler)

srv.UnUse("middleware-key")


srv.AddHandler(messageID2, handler2)

srv.Use("middleware-key", middleware)
srv.AddHandler(messageID3, handler3)
srv.UnUse("middleware-key")

router-middleware

only specific handler will be affected

srv.AddHandler(messageID, middleware, handler)
Order control
  • Message flow passes in an order of global-middleware -> anchor-middleware -> router-middleware.
  • To stop message flow, using c.Abort().
  • To execute or pass to next, using c.Next().

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL