http

package
v0.0.0-...-bdd1743 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package http provides an HTTP frontend for the agent baker service. This is a simple HTTP server that routes requests to the appropriate backend agent baker service.

Usage is simple:

verMap, err := versions.New()
if err != nil {
	panic(err)
}

serv, err := New(verMap)
if err != nil {
	panic(err)
}

panic(serv.ListenAndServe(*addr))

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Server) error

Option is an option for the New() constructor. This is currently unused.

type Server

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

Server provides an HTTP frontend that routes requests to the appropriate backend agent baker service.

func New

func New(mapping versions.Mapping, options ...Option) (*Server, error)

New creates a new Server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

ListenAndServe starts the server on the given address. This is a blocking call. It returns an error if the server fails to start. addr should be a string in the format "host:port".

type VersionedReq

type VersionedReq[T any] struct {
	// ABVersion is the Agent Baker version. This must be set to a valid version
	// or "latest".
	ABVersion versions.Version
	// Req is the request to be sent to the agent baker service.
	Req T
}

VersionedReq is a request that includes an Agent Baker version.

Jump to

Keyboard shortcuts

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