Neo provides API for handling and emiting events. You can emit and handle your custom events too.

Basic examples

Emit and receive events on application object.

app.On("error", func(data interface{}) {
    // implementation for error handler
app.Emit("someevent", eventData)

Emit and receive events on Context object.

app.Get("/", func(ctx *neo.Ctx) (int, error) {
    ctx.On("someevent", func(data interface{}) {
        // implementation for someevent handler
app.Get("/", func(ctx *neo.Ctx) (int, error) {
    ctx.Emit("someevent", eventData)

Every Emit will be executed in new goroutine, so it won’t block.

If you want to use events on your custom structures, you can embed aux.EBus like this:

import ""

type MyType struct {
    // the rest

Then your can emit and listen for events on MyType struct instances.

Neo events


In case of any panics in your application, error event will be emitted, so you will have opportunity to log panic and similar.