github.com/cilium/cilium@v1.16.2/api/v1/kvstoremesh/server/restapi/cluster/get_cluster.go (about)

     1  // Code generated by go-swagger; DO NOT EDIT.
     2  
     3  // Copyright Authors of Cilium
     4  // SPDX-License-Identifier: Apache-2.0
     5  
     6  package cluster
     7  
     8  // This file was generated by the swagger tool.
     9  // Editing this file might prove futile when you re-run the generate command
    10  
    11  import (
    12  	"net/http"
    13  
    14  	"github.com/go-openapi/runtime/middleware"
    15  )
    16  
    17  // GetClusterHandlerFunc turns a function with the right signature into a get cluster handler
    18  type GetClusterHandlerFunc func(GetClusterParams) middleware.Responder
    19  
    20  // Handle executing the request and returning a response
    21  func (fn GetClusterHandlerFunc) Handle(params GetClusterParams) middleware.Responder {
    22  	return fn(params)
    23  }
    24  
    25  // GetClusterHandler interface for that can handle valid get cluster params
    26  type GetClusterHandler interface {
    27  	Handle(GetClusterParams) middleware.Responder
    28  }
    29  
    30  // NewGetCluster creates a new http.Handler for the get cluster operation
    31  func NewGetCluster(ctx *middleware.Context, handler GetClusterHandler) *GetCluster {
    32  	return &GetCluster{Context: ctx, Handler: handler}
    33  }
    34  
    35  /*
    36  	GetCluster swagger:route GET /cluster cluster getCluster
    37  
    38  Retrieve the list of remote clusters and their status
    39  */
    40  type GetCluster struct {
    41  	Context *middleware.Context
    42  	Handler GetClusterHandler
    43  }
    44  
    45  func (o *GetCluster) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
    46  	route, rCtx, _ := o.Context.RouteInfo(r)
    47  	if rCtx != nil {
    48  		*r = *rCtx
    49  	}
    50  	var Params = NewGetClusterParams()
    51  	if err := o.Context.BindValidRequest(r, route, &Params); err != nil { // bind params
    52  		o.Context.Respond(rw, r, route.Produces, route, err)
    53  		return
    54  	}
    55  
    56  	res := o.Handler.Handle(Params) // actually handle the request
    57  	o.Context.Respond(rw, r, route.Produces, route, res)
    58  
    59  }