// Accept generates a handler that writes a 406 Not Acceptable response if none of the types match.
772051
func Accept(ctypes ...string) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		a := r.Header.Get("Accept")
		for _, t := range ctypes {
			if accepts(a, t) > 0 {
				return
			}
		}
		w.WriteHeader(http.StatusNotAcceptable)
	}
}
153944
func (server *Server) Accept(lis net.Listener) {
	for {
		conn, err := lis.Accept()
		if err != nil {
			log.Fatal("rpc.Serve: accept:", err.Error()) // TODO(r): exit?
		}
		go server.ServeConn(conn)
	}
}
87826
func (h *httpForwarder) Accept() (net.Conn, error) {
	conn := <-h.connChan
	return conn, nil
}
871011
func (listen *StopListener) Accept() (net.Conn, error) {
	conn, err := listen.TCPListener.Accept()
	if !listen.active {
		return nil, StopRequestError{} // ### return, stop requested ###
	}
	if err != nil {
		return nil, err // ### return, error ###
	}

	return conn, err
}
405067
func (r *Regexp) Accept(s int, b byte) int {
	if s < len(r.dfa.states) {
		return r.dfa.states[s].next[b]
	}
	return 0
}
547677
func (v *KeyEncryptionAlgorithm) Accept(value interface{}) error {
	var tmp KeyEncryptionAlgorithm
	switch x := value.(type) {
	case string:
		tmp = KeyEncryptionAlgorithm(x)
	case KeyEncryptionAlgorithm:
		tmp = x
	default:
		return errors.Errorf(`invalid type for jwa.KeyEncryptionAlgorithm: %T`, value)
	}
	switch tmp {
	case A128GCMKW, A128KW, A192GCMKW, A192KW, A256GCMKW, A256KW, DIRECT, ECDH_ES, ECDH_ES_A128KW, ECDH_ES_A192KW, ECDH_ES_A256KW, PBES2_HS256_A128KW, PBES2_HS384_A192KW, PBES2_HS512_A256KW, RSA1_5, RSA_OAEP, RSA_OAEP_256:
	default:
		return errors.Errorf(`invalid jwa.KeyEncryptionAlgorithm value`)
	}

	*v = tmp
	return nil
}
80487
func (p *ProtoListener) Accept() (net.Conn, error) {
	c, ok := <-p.connection
	if !ok {
		return nil, fmt.Errorf("mux: listener closed")
	}
	return c, nil
}
1129287
func (l *i2pListener) Accept() (c net.Conn, err error) {
	if l.session == nil {
		err = errors.New("session closed")
		return
	}
	var nc net.Conn
	nc, err = l.session.OpenControlSocket()
	if err == nil {
		_, err = fmt.Fprintf(nc, "STREAM ACCEPT ID=%s SILENT=false\n", l.session.Name())
		if err == nil {
			r := bufio.NewReader(nc)
			var line string
			// read response line
			line, err = r.ReadString(10)
			if err == nil {
				sc := bufio.NewScanner(strings.NewReader(line))
				sc.Split(bufio.ScanWords)
				for sc.Scan() {
					text := sc.Text()
					upper := strings.ToUpper(text)
					if upper == "STREAM" {
						continue
					}
					if upper == "RESULT" {
						continue
					}
					if upper == "RESULT=OK" {
						// we good
						break
					}
					// error
					err = errors.New(text)
				}
			}
			// read address line
			line, err = r.ReadString(10)
			if err == nil {
				// we got a new connection yeeeeh
				c = &I2PConn{
					c:     nc,
					laddr: l.laddr,
					raddr: I2PAddr(line[:len(line)-1]),
				}
			}
		}
		if c == nil {
			// we didn't get a connection
			nc.Close()
		}
	}
	return
}
1160306
func (f *FST) Accept(addr int, b byte) int {
	next, _ := f.AcceptWithVal(addr, b)
	return next
}
1074060
func (f FilterFunc) Accept(o *mesos.Offer) bool {
	if f == nil {
		return true
	}
	return f(o)
}
131508
func (l *Listener) accept() {
	var wg sync.WaitGroup
	defer func() {
		wg.Wait() // must happen before teardown
		l.teardown()
	}()

	// catching the error here is odd. doing what net/http does:
	// http://golang.org/src/net/http/server.go?s=51504:51550#L1728
	// Using the lib: https://godoc.org/github.com/jbenet/go-temp-err-catcher
	var catcher tec.TempErrCatcher

	// rate limit concurrency
	limit := make(chan struct{}, AcceptConcurrency)

	// loop forever accepting connections
	for {
		conn, err := l.netList.Accept()
		if err != nil {
			if catcher.IsTemporary(err) {
				continue
			}
			l.acceptErr <- fmt.Errorf("peerstream listener failed: %s", err)
			return // ok, problems. bail.
		}

		// add conn to swarm and listen for incoming streams
		// do this in a goroutine to avoid blocking the Accept loop.
		// note that this does not rate limit accepts.
		limit <- struct{}{} // sema down
		wg.Add(1)
		go func(conn net.Conn) {
			defer func() { <-limit }() // sema up
			defer wg.Done()

			conn2, err := l.swarm.addConn(conn, true)
			if err != nil {
				l.acceptErr <- err
				return
			}
			conn2.groups.AddSet(&l.groups) // add out groups
		}(conn)
	}
}
891430
func (s *NetServer) Accept() (Conn, error) {
	// ensure write delay default
	if s.MaxWriteDelay == 0 {
		s.MaxWriteDelay = 10 * time.Millisecond
	}

	conn, err := s.listener.Accept()
	if err != nil {
		return nil, err
	}

	return NewNetConn(conn, s.MaxWriteDelay), nil
}
860960
func (ep *endpoint) Accept() (tcpip.Endpoint, *waiter.Queue, *tcpip.Error) {
	return nil, nil, tcpip.ErrNotSupported
}
1091047
func (s *invitationServiceImpl) Accept(ctx context.Context, token uuid.UUID) (string, string, error) {

	// Locate the invitation
	inv, err := s.Repositories().InvitationRepository().FindByAcceptCode(ctx, token)

	if err != nil {
		return "", "", errs.Wrapf(err, "something went wrong while finding invitation with accept code")
	}

	// get redirect urls
	redirectOnSuccess := inv.SuccessRedirectURL
	redirectOnFailure := inv.FailureRedirectURL

	// get identity for invitation
	currentIdentityID := inv.IdentityID
	identity, err := s.Repositories().Identities().LoadWithUser(ctx, currentIdentityID)
	if err != nil {
		return "", redirectOnFailure, errs.Wrapf(err, "failed to load identity for invitee %d", currentIdentityID)
	}

	if identity.User.Banned {
		return "", redirectOnFailure, autherrors.NewUnauthorizedError("user banned")
	}

	var resourceID string

	err = s.ExecuteInTransaction(func() error {

		// If this invitation is for an identity
		if inv.InviteTo != nil {
			inviteToIdentity, err := s.Repositories().Identities().Load(ctx, *inv.InviteTo)
			if err != nil {
				return err
			}

			// If the invitation is for a membership, add a membership record
			if inv.Member {
				err = s.Repositories().Identities().AddMember(ctx, inviteToIdentity.ID, currentIdentityID)
				if err != nil {
					return err
				}
			}

			roles, err := s.Repositories().InvitationRepository().ListRoles(ctx, inv.InvitationID)
			if err != nil {
				return err
			}

			// If the invitation includes role assignments, assign them
			inviteToIdentityResourceID := inviteToIdentity.IdentityResourceID.String
			for _, role := range roles {
				ir := &repository.IdentityRole{
					IdentityID: currentIdentityID,
					RoleID:     role.RoleID,
					ResourceID: inviteToIdentityResourceID,
				}

				err = s.Repositories().IdentityRoleRepository().Create(ctx, ir)
				if err != nil {
					return err
				}
			}

			// Delete the invitation
			err = s.Repositories().InvitationRepository().Delete(ctx, inv.InvitationID)
			if err != nil {
				return errs.Wrap(err, "failed to create identity role")
			}

			// Return the identity ID
			resourceID = inviteToIdentity.IdentityResourceID.String

		} else if inv.ResourceID != nil {
			inviteToResource, err := s.Repositories().ResourceRepository().Load(ctx, *inv.ResourceID)
			if err != nil {
				return errs.Wrapf(err, "failed to load resource %s", resourceID)
			}

			roles, err := s.Repositories().InvitationRepository().ListRoles(ctx, inv.InvitationID)
			if err != nil {
				return errs.Wrapf(err, "failed to load roles for invitation %d", inv.InvitationID)
			}

			for _, role := range roles {
				ir := &repository.IdentityRole{
					IdentityID: currentIdentityID,
					RoleID:     role.RoleID,
					ResourceID: inviteToResource.ResourceID,
				}

				err = s.Repositories().IdentityRoleRepository().Create(ctx, ir)
				if err != nil {
					return err
				}
			}

			// Delete the invitation
			err = s.Repositories().InvitationRepository().Delete(ctx, inv.InvitationID)
			if err != nil {
				return errs.Wrapf(err, "failed to delete invitation %d", inv.InvitationID)
			}

			// Set the resource ID
			resourceID = inviteToResource.ResourceID
		}

		return nil
	})

	if err != nil {
		return "", redirectOnFailure, err
	}

	// Return the resource ID and redirect path
	return resourceID, redirectOnSuccess, nil
}
717626
func (l *PipeListener) Accept() (net.Conn, error) {
	c, err := l.AcceptPipe()
	for err == error_no_data {
		// Ignore clients that connect and immediately disconnect.
		c, err = l.AcceptPipe()
	}
	if err != nil {
		return nil, err
	}
	return c, nil
}
849142
func (n *ValuesExpr) Accept(v Visitor) (Node, bool) {
	newNode, skipChildren := v.Enter(n)
	if skipChildren {
		return v.Leave(newNode)
	}
	n = newNode.(*ValuesExpr)
	node, ok := n.Column.Accept(v)
	if !ok {
		return n, false
	}
	n.Column = node.(*ColumnNameExpr)
	return v.Leave(n)
}
244555
func (n *negotiator) Accepts(ctype string) float64 {
	return accepts(n.r.Header.Get("Accept"), ctype)
}