code: func (o *Options) Handler(next http.Handler) http.HandlerFunc {
  	// Allow default headers if nothing is specified.
  	if len(o.AllowHeaders) == 0 {
  		o.AllowHeaders = defaultAllowHeaders
  	}
  
  	for _, origin := range o.AllowOrigins {
  		pattern := regexp.QuoteMeta(origin)
  		pattern = strings.Replace(pattern, "\\*", ".*", -1)
  		pattern = strings.Replace(pattern, "\\?", ".", -1)
  		allowOriginPatterns = append(allowOriginPatterns, "^"+pattern+"$")
  	}
  
  	return func(w http.ResponseWriter, req *http.Request) {
  		if origin := req.Header.Get(headerOrigin); origin != "" {
  			for key, value := range o.Header(origin, req) {
  				w.Header().Set(key, value)
  			}
  			if req.Method == "OPTIONS" {
  				w.WriteHeader(200)
  				return
  			}
  		}
  		next.ServeHTTP(w, req)
  	}
  }
docs: // Allows CORS for requests those match the provided options.