github.com/rancher/longhorn-engine@v0.6.2/replica/rest/replica.go (about)

     1  package rest
     2  
     3  import (
     4  	"github.com/rancher/go-rancher/api"
     5  	"github.com/rancher/go-rancher/client"
     6  	"net/http"
     7  )
     8  
     9  func (s *Server) ListReplicas(rw http.ResponseWriter, req *http.Request) error {
    10  	apiContext := api.GetApiContext(req)
    11  	resp := client.GenericCollection{}
    12  	resp.Data = append(resp.Data, s.Replica(apiContext))
    13  
    14  	apiContext.Write(&resp)
    15  	return nil
    16  }
    17  
    18  func (s *Server) Replica(apiContext *api.ApiContext) *Replica {
    19  	state, info := s.s.Status()
    20  	return NewReplica(apiContext, state, info, s.s.Replica())
    21  }
    22  
    23  func (s *Server) doOp(req *http.Request, err error) error {
    24  	if err != nil {
    25  		return err
    26  	}
    27  
    28  	apiContext := api.GetApiContext(req)
    29  	apiContext.Write(s.Replica(apiContext))
    30  	return nil
    31  }