auth

Paddy 2015-01-14 Parent:c03b5eb3179e Child:e000b1c24fc0

115:fa8ee6a4507c Go to Latest

auth/context.go

Turn AddEndpoint into AddEndpoints. Because one is a special case of many, it makes sense to be able to add multiple endpoints in a single call to the database. So we've converted the AddEndpoint method into an AddEndpoints method and updated our tests appropriately. We also filled in the errors when creating a client through the API, and moved things around to optimize for the maximum number of errors returned in a single call.

History
     1.1 --- a/context.go	Sat Jan 10 04:16:07 2015 -0500
     1.2 +++ b/context.go	Wed Jan 14 00:23:30 2015 -0500
     1.3 @@ -107,13 +107,13 @@
     1.4  	return c.clients.listClientsByOwner(ownerID, num, offset)
     1.5  }
     1.6  
     1.7 -// AddEndpoint stores the specified Endpoint in the clientStore associated with the Context,
     1.8 -// and associates the newly-stored Endpoint with the Client specified by the passed ID.
     1.9 -func (c Context) AddEndpoint(client uuid.ID, endpoint Endpoint) error {
    1.10 +// AddEndpoints stores the specified Endpoints in the clientStore associated with the Context,
    1.11 +// and associates the newly-stored Endpoints with the Client specified by the passed ID.
    1.12 +func (c Context) AddEndpoints(client uuid.ID, endpoints []Endpoint) error {
    1.13  	if c.clients == nil {
    1.14  		return ErrNoClientStore
    1.15  	}
    1.16 -	return c.clients.addEndpoint(client, endpoint)
    1.17 +	return c.clients.addEndpoints(client, endpoints)
    1.18  }
    1.19  
    1.20  // RemoveEndpoint deletes the Endpoint with the specified ID from the clientStore associated