server

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlagData added in v0.7.0

type FlagData struct {
	// Addr is the address the HTTP server will bind to.
	Addr string

	// BuildInfo contains the build information for rh. Set by goreleaser.
	BuildInfo map[string]string

	// Details determines if header details should be shown with the request,
	Details bool

	// LogFile contains the path and filename to the log file which the server
	// will write to if log flag is passed.
	LogFile string

	// Port is the port the HTTP server will run on.
	Port int

	// Protocol is the protocol that the server will use to handle incoming requests.
	Protocol string

	// ResponseCode is the response which our endpoint will return.
	// Default is 200 if no response code is passed.
	ResponseCode int

	// Web determines if we use the web renderer, otherwise defaults to the printer renderer.
	Web bool

	// WebAddress is the address the web UI will bind to.
	WebAddress string

	// WebPort defines which port we host the web renderer at, defaults to 8081.
	WebPort int
}

FlagData contains the data from the CLI flags.

type Server added in v0.7.0

type Server struct {
	// FlagData contains the data from the CLI flags.
	FlagData

	// Protocol which we receive incoming requests to. The protocol uses a channel
	// to send incoming requests to the renderers.
	Protocol protocol.Protocol

	// Renderers contains a slice of renderer's. Each will run within it's own
	// goroutine.
	Renderers []renderer.Renderer
}

Server orchestrates the start and channels for the protocol and renderers.

func (*Server) Start added in v0.7.0

func (s *Server) Start()

Start handles all of the orchestration.

Prints the CLI header which we use to show flags passed to the CLI(ie: port).

Creates a waitgroup for each goroutine.

Creates a channel between the protocol and renderers to handle incoming request payloads and exiting due to errors.

Blocks main program until all goroutines are returned. In most cases the user will force exit the CLI from the terminal.

Jump to

Keyboard shortcuts

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