func SelfdestructFn(limit float64, fn func(ctx context.Context) bool) func(chi.Handler) chi.Handler {
	return func(next chi.Handler) chi.Handler {
		fn := func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
			if MemoryUsage() > limit {
				go selfdestruct(ctx, fn)
			}

			next.ServeHTTPC(ctx, w, r)
		}
		return chi.HandlerFunc(fn)
	}
}
// SelfdestructFn is a version of Selfdestruct that accepts a custom
// termination function ( func(context.Context) bool ) that handles the process
// shutdown.
// Use it if your app requires extra steps to gracefully shut down.
SelfdestructFn is a version of Selfdestruct that accepts a custom
termination function ( func(context.Context) bool ) that handles the process
shutdown.
Use it if your app requires extra steps to gracefully shut down.
// SelfdestructFn is a version of Selfdestruct that accepts a custom // termination function ( func ( context . Context ) bool ) that handles the process // shutdown . // Use it if your app requires extra steps to gracefully shut down .
func SelfdestructFn(limit float64, fn func(ctx context.Context) bool) func(chi.Handler) chi.Handler {
	return func(next chi.Handler) chi.Handler {
		fn := func(ctx context.Context, w http.ResponseWriter, r *http.Request) {
			if MemoryUsage() > limit {
				go selfdestruct(ctx, fn)
			}
			next.ServeHTTPC(ctx, w, r)
		}
		return chi.HandlerFunc(fn)
	}
}
func SelfdestructFn ( limit float64 , fn func ( ctx context . Context ) bool ) func ( chi . Handler ) chi . Handler { return func ( next chi . Handler ) chi . Handler { fn := func ( ctx context . Context , w http . ResponseWriter , r * http . Request ) { if MemoryUsage ( ) > limit { go selfdestruct ( ctx , fn ) } next . ServeHTTPC ( ctx , w , r ) } return chi . HandlerFunc ( fn ) } }
SelfdestructFn is a version of Selfdestruct that accepts a custom
termination function ( func(context.Context) bool ) that handles the process
shutdown.
SelfdestructFn is a version of Selfdestruct that accepts a custom termination function ( func ( context . Context ) bool ) that handles the process shutdown .