sock

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimeout           = fmt.Errorf("unix socket timeout")
	ErrConnectionRefused = fmt.Errorf("unix socket connection failed")
)
View Source
var (
	ErrServerRequestedShutdown = errors.New("socket frontend is requested to shutdown")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	Addr string
}

Client is a unix socket client that can send requests to the frontend over HTTP.

func (*Client) Request

func (cl *Client) Request(method, url string) (string, error)

Request sends a request to the frontend and returns the response.

type Config

type Config struct {
	Addr        string
	HandlerFunc HttpHandlerFunc
}

type HttpHandlerFunc

type HttpHandlerFunc func(w http.ResponseWriter, r *http.Request)

HttpHandlerFunc is a function that handles HTTP requests.

type Server

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

Server is a unix socket frontend that passes http requests to HandlerFunc.

func NewServer

func NewServer(c *Config) (*Server, error)

NewServer creates a new unix socket frontend.

func (*Server) Serve

func (svr *Server) Serve(listen chan error) error

Serve starts listening and serving requests.

func (*Server) Shutdown

func (svr *Server) Shutdown() error

Shutdown stops the frontend.

Jump to

Keyboard shortcuts

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