http

package
v0.0.0-...-8164673 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(err error, status int, message string) error

NewError returns new error message

Types

type ClientError

type ClientError interface {
	Error() string
	Body() ([]byte, error)
	Headers() (int, map[string]string)
}

ClientError is the interface that wraps methods related to error on the client side

type Error

type Error struct {
	Cause   error  `json:"-"`
	Message string `json:"message"`
	Status  int    `json:"-"`
}

Error represents a detail error message

func (*Error) Body

func (e *Error) Body() ([]byte, error)

Body returns response body from error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Headers

func (e *Error) Headers() (int, map[string]string)

Headers returns status and header

type Server

type Server struct {
	Addr   string
	Domain string

	SubscriptionService mailbus.SubscriptionService
	NewsletterService   mailbus.NewsletterService
	QueueService        mailbus.QueueService
	// contains filtered or unexported fields
}

Server represents HTTP server

func NewServer

func NewServer() (*Server, error)

NewServer create new HTTP server

func (*Server) Close

func (s *Server) Close() error

Close shutdowns HTTP server

func (*Server) ConsumeAndSendNewsletter

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

func (*Server) Error

func (s *Server) Error(fn appHandler) http.HandlerFunc

Error parse HTTP error and write to header and body

func (*Server) Open

func (s *Server) Open() (err error)

Open opens a connection to HTTP server

func (*Server) Port

func (s *Server) Port() int

Port returns server port

func (*Server) Scheme

func (s *Server) Scheme() string

Scheme returns scheme

func (*Server) URL

func (s *Server) URL() string

URL returns server URL

func (*Server) UseTLS

func (s *Server) UseTLS() bool

UseTLS checks if server use TLS or not

Jump to

Keyboard shortcuts

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