func volumeInfo(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	ctx := r.Context()
	v, err := servicemanager.Volume.Get(ctx, r.URL.Query().Get(":name"))
	if err != nil {
		if err == volumeTypes.ErrVolumeNotFound {
			return &errors.HTTP{Code: http.StatusNotFound, Message: err.Error()}
		}
		return err
	}
	canRead := permission.Check(t, permission.PermVolumeRead, contextsForVolume(v)...)
	if !canRead {
		return permission.ErrUnauthorized
	}
	v.Binds, err = servicemanager.Volume.Binds(ctx, v)
	if err != nil {
		return err
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(&v)
}
title: volume info
path: /volumes/{name}
method: GET
produce: application/json
responses:
200: Show volume
401: Unauthorized
404: Volume not found
package api
import (
	"encoding/json"
	"net/http"
	"time"
	"github.com/tsuru/tsuru/auth"
	"github.com/tsuru/tsuru/errors"
	"github.com/tsuru/tsuru/event"
	tsuruIo "github.com/tsuru/tsuru/io"
	"github.com/tsuru/tsuru/permission"
	"github.com/tsuru/tsuru/provision/pool"
	"github.com/tsuru/tsuru/servicemanager"
	permTypes "github.com/tsuru/tsuru/types/permission"
	volumeTypes "github.com/tsuru/tsuru/types/volume"
)
func volumeFilterByContext(contexts []permTypes.PermissionContext) *volumeTypes.Filter {
	filter := &volumeTypes.Filter{}
contextsLoop:
	for _, c := range contexts {
		switch c.CtxType {
		case permTypes.CtxGlobal:
			filter = nil
			break contextsLoop
		case permTypes.CtxTeam:
			filter.Teams = append(filter.Teams, c.Value)
		case permTypes.CtxVolume:
			filter.Names = append(filter.Names, c.Value)
		case permTypes.CtxPool:
			filter.Pools = append(filter.Pools, c.Value)
		}
	}
	return filter
}
func contextsForVolume(v *volumeTypes.Volume) []permTypes.PermissionContext {
	return []permTypes.PermissionContext{
		permission.Context(permTypes.CtxVolume, v.Name),
		permission.Context(permTypes.CtxTeam, v.TeamOwner),
		permission.Context(permTypes.CtxPool, v.Pool),
	}
}
func volumesList(w http.ResponseWriter, r *http.Request, t auth.Token) error {
	ctx := r.Context()
	contexts := permission.ContextsForPermission(t, permission.PermVolumeRead)
	if len(contexts) == 0 {
		w.WriteHeader(http.StatusNoContent)
		return nil
	}
	volumes, err := servicemanager.Volume.ListByFilter(ctx, volumeFilterByContext(contexts))
	if err != nil {
		return err
	}
	if len(volumes) == 0 {
		w.WriteHeader(http.StatusNoContent)
		return nil
	}
	w.Header().Set("Content-Type", "application/json")
	return json.NewEncoder(w).Encode(volumes)
}