A useful gas that used to recover from panics for the web applications built using Air.
Open your terminal and execute
$ go get github.com/air-gases/defibrillator
done.
The only requirement is the Go, at least v1.13.
Create a file named main.go
package main
import (
"github.com/air-gases/defibrillator"
"github.com/aofei/air"
)
func main() {
a := air.Default
a.DebugMode = true
a.Pregases = []air.Gas{
defibrillator.Gas(defibrillator.GasConfig{}),
}
a.GET("/", func(req *air.Request, res *air.Response) error {
panic("SOME TERRIBLE THINGS HAPPENED!")
return res.WriteString("This method will never be executed.")
})
a.Serve()
}
and run it
$ go run main.go
then visit http://localhost:8080
.
If you want to discuss Defibrillator, or ask questions about it, simply post questions or ideas here.
If you want to help build Defibrillator, simply follow this to send pull requests here.
This project is licensed under the MIT License.
License can be found here.