Package web implements etcd-play web.



    This section is empty.


    View Source
    var (
    	// ErrNoEndpoint is returned when client request has no target endpoint.
    	ErrNoEndpoint = "no endpoint is given"


    This section is empty.


    type ClientRequest

    type ClientRequest struct {
    	Action      string // 'write', 'stress', 'delete', 'get', 'stop-node', 'restart-node'
    	RangePrefix bool   // 'delete', 'get'
    	Endpoints   []string
    	KeyValue    KeyValue

      ClientRequest defines client requests.

      type ClientResponse

      type ClientResponse struct {
      	ClientRequest ClientRequest
      	Success       bool
      	Result        string
      	ResultLines   []string
      	KeyValues     []KeyValue

        ClientResponse translates client's GET response in frontend-friendly format.

        type Connect

        type Connect struct {
        	WebPort int
        	User    string
        	Deleted bool

          Connect contains initial server state.

          type ContextAdapter

          type ContextAdapter struct {
          	// contains filtered or unexported fields

            ContextAdapter wraps context handler.

            func (*ContextAdapter) ServeHTTP

            func (ca *ContextAdapter) ServeHTTP(w http.ResponseWriter, req *http.Request)

            type ContextHandler

            type ContextHandler interface {
            	ServeHTTPContext(context.Context, http.ResponseWriter, *http.Request) error

              ContextHandler handles ServeHTTP with context.

              type ContextHandlerFunc

              type ContextHandlerFunc func(context.Context, http.ResponseWriter, *http.Request) error

                ContextHandlerFunc defines HandlerFunc function signature to wrap context.

                func (ContextHandlerFunc) ServeHTTPContext

                func (f ContextHandlerFunc) ServeHTTPContext(ctx context.Context, w http.ResponseWriter, req *http.Request) error

                  ServeHTTPContext serve HTTP requests with context.

                  type KeyValue

                  type KeyValue struct {
                  	Key   string
                  	Value string

                    KeyValue defines key-value pair.

                    type Server

                    type Server struct {
                    	// contains filtered or unexported fields

                      Server warps http.Server.

                      func StartServer

                      func StartServer(port int) (*Server, error)

                        StartServer starts a backend webserver with stoppable listener.

                        func (*Server) Stop

                        func (srv *Server) Stop()

                          Stop stops the server. Useful for testing.

                          func (*Server) StopNotify

                          func (srv *Server) StopNotify() <-chan struct{}

                            StopNotify returns receive-only stop channel to notify the server has stopped.

                            type ServerStatus

                            type ServerStatus struct {
                            	// PlaygroundActive is true when the user is still active in '/play'.
                            	PlaygroundActive bool
                            	// ServerUptime is the duration since last deploy.
                            	ServerUptime string
                            	// ServerVisits is the number visits since last deploy.
                            	ServerVisits uint64
                            	// UserN is the number of online users.
                            	UserN int
                            	// Users is a slice of users with real IPs being masked.
                            	// Maximum 20 users are returned.
                            	Users []string
                            	// MemberStatuses contains all node statuses.
                            	MemberStatuses []clusterpb.MemberStatus

                              ServerStatus defines server status. Encode without json tags to make it parsable by Typescript.