http

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2019 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(host url.URL, conf ClientConfig) (trn.Client, error)

NewClient creates a new API client instance

func NewServer

func NewServer(conf ServerConfig) (trn.Server, error)

NewServer creates a new unencrypted JSON based HTTP transport. Use NewSecure to enable encryption instead

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents an HTTP client implementation

func (*Client) Auth

func (c *Client) Auth(sessionKey string) (*gqlmod.Session, error)

Auth implements the transport.Client interface

func (*Client) Query

func (c *Client) Query(
	query string,
	result interface{},
) error

Query implements the transport.Client interface

func (*Client) QueryVar

func (c *Client) QueryVar(
	query string,
	vars map[string]interface{},
	result interface{},
) error

QueryVar implements the transport.Client interface

func (*Client) SignIn

func (c *Client) SignIn(email, password string) (*gqlmod.Session, error)

SignIn implements the transport.Client interface

func (*Client) SignInDebug

func (c *Client) SignInDebug(username, password string) error

SignInDebug implements the transport.Client interface

type ClientConfig added in v1.2.0

type ClientConfig struct {
	Timeout time.Duration
}

ClientConfig defines the HTTP client transport layer configuration

func (*ClientConfig) SetDefaults added in v1.2.0

func (conf *ClientConfig) SetDefaults()

SetDefaults sets the default configuration

type GraphResponse

type GraphResponse struct {
	Data  interface{}         `json:"d,omitempty"`
	Error *GraphResponseError `json:"e,omitempty"`
}

GraphResponse represents a response object

type GraphResponseError

type GraphResponseError struct {
	Code    string `json:"c,omitempty"`
	Message string `json:"m,omitempty"`
}

GraphResponseError represents a response error object

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents an HTTP based server transport implementation

func (*Server) Addr

func (t *Server) Addr() url.URL

Addr returns the host address URL. Blocks until the listener is initialized and the actual address is known

func (*Server) Config added in v1.2.0

func (t *Server) Config() ServerConfig

Config returns the active configuration

func (*Server) Init

func (t *Server) Init(
	onGraphQuery trn.OnGraphQuery,
	onAuth trn.OnAuth,
	onDebugAuth trn.OnDebugAuth,
	onDebugSess trn.OnDebugSess,
	debugLog *log.Logger,
	errorLog *log.Logger,
) error

Init implements the transport.Transport interface

func (*Server) Run

func (t *Server) Run() error

Run implements the transport.Transport interface

func (*Server) ServeHTTP

func (t *Server) ServeHTTP(resp http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface

func (*Server) Shutdown

func (t *Server) Shutdown(ctx context.Context) error

Shutdown implements the transport.Transport interface

type ServerConfig added in v1.2.0

type ServerConfig struct {
	Host              string
	KeepAliveDuration time.Duration
	TLS               *ServerTLS
	Playground        bool
}

ServerConfig defines the HTTP server transport layer configurations

func (*ServerConfig) Prepare added in v1.2.0

func (conf *ServerConfig) Prepare() error

Prepare sets defaults and validates the configurations

type ServerTLS

type ServerTLS struct {
	Config              *tls.Config
	CertificateFilePath string
	PrivateKeyFilePath  string
}

ServerTLS represents the TLS configurations

func (*ServerTLS) Clone

func (stls *ServerTLS) Clone() *ServerTLS

Clone creates an exact detached copy of the server TLS configurations

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL