http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2020 License: MIT Imports: 16 Imported by: 2

Documentation

Overview

Package http implements the HTTP transport protocol.

Index

Constants

View Source
const (
	DebugMode   = "debug"
	TestMode    = "testing"
	ReleaseMode = "release"
)

Variables

Functions

func NewRouter

func NewRouter(o *Options, logger *zap.Logger, group router.Group, validator *validator.CustomValidator) (*echo.Echo, error)

NewRouter returns a new Echo router.

Types

type Options

type Options struct {
	// The hostname of the HTTP server.
	Host string

	// The port of the HTTP server.
	Port int

	// Read timeout for the HTTP server.
	ReadTimeout time.Duration

	// Write timeout for the HTTP server.
	WriteTimeout time.Duration

	// Mode of the HTTP server. Includes DebugMode, TestMode, and ReleaseMode.
	Mode string
}

Options for the HTTP server.

func NewOptions

func NewOptions(v *viper.Viper) (*Options, error)

NewOptions creates a new set of o for the HTTP server.

func (*Options) Addr

func (o *Options) Addr() string

Addr returns the address of the HTTP server. The format is "host:port".

type Server

type Server struct {
	Name    string
	Version string

	*Options
	// contains filtered or unexported fields
}

Server is the HTTP server.

func New

func New(o *Options, logger *zap.Logger, router *echo.Echo, registrar registry.Registrar) *Server

New creates a new HTTP server.

func (*Server) GetID

func (s *Server) GetID() string

GetID returns the unique identifier of the server. It is useful when a service starts more than one server.

func (*Server) IntranetAddr

func (s *Server) IntranetAddr() string

func (*Server) Service

func (s *Server) Service() *registry.ServiceInstance

func (*Server) Start

func (s *Server) Start() error

Start http server.

func (*Server) Stop

func (s *Server) Stop() error

Stop http server.

Jump to

Keyboard shortcuts

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