// Apply implements `web.Filter` interface.
344002
func (r *Recover) Apply(next web.HandlerFunc) web.HandlerFunc {
	if r.StackSize == 0 {
		r.StackSize = 4 << 10 // 4 KB
	}

	pool := sync.Pool{
		New: func() interface{} {
			return make([]byte, r.StackSize)
		},
	}

	return func(ctx web.Context) error {
		defer func() {
			if e := recover(); e != nil {
				err := errors.Convert(e)
				if r.StackEnabled {
					stack := pool.Get().([]byte)
					length := runtime.Stack(stack, false)
					ctx.Logger().Errorf("PANIC: %s, stack: %s", err, stack[:length])
					pool.Put(stack)
				}
				ctx.Error(err)
			}
		}()

		return next(ctx)
	}
}
485632
func (f *IntFlag) Apply(set *flag.FlagSet) {
	f.set = set
	f.IntFlag.Apply(set)
}
1182594
func (cs Checksums) Apply(d []byte) []byte {
	d = append([]byte(nil), d...)
	for _, c := range cs {
		setU32(d, c.Offset, c.Value)
	}
	return d
}
191909
func (c *Conf) Apply(cfg *Config) (*Config, error) {
	// Set the Config's listening addresses if they are empty.
	if cfg.ListenAddrs == nil {
		// Without a network, we will be unable to resolve the listening
		// addresses.
		if cfg.Net == nil {
			return nil, ErrNoNetwork
		}

		// If no addresses are specified by the Config, we will resort
		// to the default peer port.
		if len(c.RawListeners) == 0 {
			addr := DefaultPeerPortStr
			c.RawListeners = append(c.RawListeners, addr)
		}

		// Normalize the raw listening addresses so that they can be
		// used by the brontide listener.
		var err error
		cfg.ListenAddrs, err = lncfg.NormalizeAddresses(
			c.RawListeners, DefaultPeerPortStr,
			cfg.Net.ResolveTCPAddr,
		)
		if err != nil {
			return nil, err
		}
	}

	// If the Config has no read timeout, we will use the parsed Conf
	// value.
	if cfg.ReadTimeout == 0 && c.ReadTimeout != 0 {
		cfg.ReadTimeout = c.ReadTimeout
	}

	// If the Config has no write timeout, we will use the parsed Conf
	// value.
	if cfg.WriteTimeout == 0 && c.WriteTimeout != 0 {
		cfg.WriteTimeout = c.WriteTimeout
	}

	return cfg, nil
}
187452
func (f *optionalMsgFields) apply(optionalMsgFields ...OptionalMsgField) {
	for _, optionalMsgField := range optionalMsgFields {
		optionalMsgField(f)
	}
}
263524
func (c *clusterOption) Apply(server *Server) {
	// TODO: support enabling/disabling clustering.
	server.mu.Lock()
	tlsRequired := c.newValue.TLSConfig != nil
	server.routeInfo.TLSRequired = tlsRequired
	server.routeInfo.TLSVerify = tlsRequired
	server.routeInfo.AuthRequired = c.newValue.Username != ""
	if c.newValue.NoAdvertise {
		server.routeInfo.ClientConnectURLs = nil
	} else {
		server.routeInfo.ClientConnectURLs = server.clientConnectURLs
	}
	server.setRouteInfoHostPortAndIP()
	server.mu.Unlock()
	server.Noticef("Reloaded: cluster")
	if tlsRequired && c.newValue.TLSConfig.InsecureSkipVerify {
		server.Warnf(clusterTLSInsecureWarning)
	}
}
331425
func (f *BoolFlag) Apply(set *flag.FlagSet) {
	f.set = set
	f.BoolFlag.Apply(set)
}
1334020
func (q *Query) ApplyFilters(objects Objects) Objects {
	for _, f := range q.Filters {
		objects = f(objects)
	}
	return objects
}
925470
func (f *GenericFlag) Apply(set *flag.FlagSet) {
	f.set = set
	f.GenericFlag.Apply(set)
}
596460
func (inj *injector) Apply(val interface{}) error {
	v := reflect.ValueOf(val)

	for v.Kind() == reflect.Ptr {
		v = v.Elem()
	}

	if v.Kind() != reflect.Struct {
		return nil // Should not panic here ?
	}

	t := v.Type()

	for i := 0; i < v.NumField(); i++ {
		f := v.Field(i)
		structField := t.Field(i)
		if f.CanSet() && (structField.Tag == "inject" || structField.Tag.Get("inject") != "") {
			ft := f.Type()
			v := inj.GetVal(ft)
			if !v.IsValid() {
				return fmt.Errorf("Value not found for type %v", ft)
			}

			f.Set(v)
		}

	}

	return nil
}
87370
func (filters FilterArray) ApplyFilter(msg *Message) (FilterResult, error) {
	for _, filter := range filters {
		result, err := filter.ApplyFilter(msg)
		if err != nil {
			return result, err
		}

		if result != FilterResultMessageAccept {
			return result, nil
		}
	}
	return FilterResultMessageAccept, nil
}
378234
func (m ClassMap) Apply(h *HTML) {
	if h.classes == nil {
		h.classes = make(map[string]struct{})
	}
	for name, active := range m {
		if !active {
			delete(h.classes, name)
			continue
		}
		h.classes[name] = struct{}{}
	}
}
1142831
func (f *StringSliceFlag) Apply(set *flag.FlagSet) {
	f.set = set
	f.StringSliceFlag.Apply(set)
}
125422
func (p Patch) Apply(doc []byte) ([]byte, error) {
	return p.ApplyIndent(doc, "")
}
580471
func (o *Options) Apply(opts ...Option) error {
	for i, opt := range opts {
		if err := opt(o); err != nil {
			return fmt.Errorf("dht option %d failed: %s", i, err)
		}
	}
	return nil
}
613609
func (pipeline *Pipeline) apply(f func(*Node)) {
	head := pipeline.source
	nodes := []*Node{head}
	for len(nodes) > 0 {
		head, nodes = nodes[0], nodes[1:]
		f(head)
		nodes = append(nodes, head.children...)
	}
}
1057939
func (x Vector) Apply(f func(float64) float64) Vector {
	y := make(Vector, len(x))

	for i, v := range x {
		y[i] = f(v)
	}
	return y
}