http

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Module exported for initialising a new Server and Client.

Functions

This section is empty.

Types

type Client

type Client struct {
	*resty.Client
}

Client is a simple wrapper around resty.Client.

func NewClient

func NewClient(cfg *config.Config) *Client

NewClient creates a new Client.

type Error

type Error struct {
	// A URI reference [RFC3986] that identifies the
	// problem type.  This specification encourages that, when
	// dereferenced, it provide human-readable documentation for the
	// problem type (e.g., using HTML [W3C.REC-html5-20141028]).  When
	// this member is not present, its value is assumed to be
	// "about:blank".
	Type string `json:"type"`
	// A short, human-readable summary of the problem
	// type.  It SHOULD NOT change from occurrence to occurrence of the
	// problem, except for purposes of localization (e.g., using
	// proactive content negotiation; see [RFC7231], Section 3.4).
	Title string `json:"title"`
	// The HTTP status code ([RFC7231], Section 6)
	// generated by the origin server for this occurrence of the problem.
	Status int `json:"status,omitempty"`
	// A human-readable explanation specific to this
	// occurrence of the problem.
	Detail string `json:"detail,omitempty"`
	// A URI reference that identifies the specific
	// occurrence of the problem.  It may or may not yield further
	// information if dereferenced.
	Instance string `json:"instance,omitempty"`
	// Extensions contains additional data.
	Extensions map[string]any `json:"extensions,omitempty"`
}

Error represents a problem details object as described in RFC 7807.

func NewError

func NewError(
	errType,
	title string,
	status int,
	detail string,
	instance string,
	exts map[string]any,
) *Error

NewError returns a new Error.

func (*Error) Error

func (e *Error) Error() string

type Server

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

Server is the main HTTP server.

func NewServer

func NewServer(
	cfg *config.Config,
	logger *logger.Logger,
	tracer *tracer.Tracer,
	spoty *spoty.Spoty,
	health *health.Checks,
	build *build.Info,
) *Server

NewServer creates a new Server.

func (*Server) Start

func (s *Server) Start() error

Start starts the server. It blocks until the server stops.

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

Stop stops the server.

type Success

type Success struct {
	Message string `json:"message"`
}

Success defines the structure for a successful response.

Jump to

Keyboard shortcuts

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