harp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPRequest

type HTTPRequest struct {
	Method      string            `json:"method"`
	URL         string            `json:"url"`
	Headers     map[string]string `json:"headers"`
	HeadersHash string            `json:"headersHash"`
	Body        string            `json:"body"`
	ResponseId  string            `json:"responseId"`
	Timestamp   time.Time         `json:"timestamp"`
}

HTTPRequest is a HTTP request from Harp to the app enclosed in a WebSocket message

type HTTPResponse

type HTTPResponse struct {
	Status     int               `json:"status"`
	StatusCode int               `json:"statusCode"`
	Headers    map[string]string `json:"headers"`
	Body       string            `json:"body"`
	ResponseId string            `json:"responseId"`
	Timestamp  time.Time         `json:"timestamp"`
	Cacheable  bool              `json:"cacheable"`
	Latency    time.Duration     `json:"latency"`
}

HTTPResponse is a HTTP response from the app to Harp enclosed in a WebSocket message

type Registration

type Registration struct {
	Name   string  `json:"name"`
	Domain string  `json:"domain"`
	Key    string  `json:"key"`
	Routes []Route `json:"routes"`
}

Registration is a registration message from an app to Harp enclosed in a WebSocket message

type Route

type Route struct {
	Name     string          `json:"name"`
	Path     string          `json:"path"`
	RegExp   string          `json:"regexp"`
	Port     int             `json:"port"`
	Domain   string          `json:"domain"`
	IPorHost string          `json:"ipOrHost"`
	Status   Status          `json:"-"` // We store the status of the route here
	Pattern  *regexp.Regexp  `json:"-"` // We store the compiled regular expression here
	Conn     *websocket.Conn `json:"-"` // We store the WebSocket connection here
	//Handler func(*HTTPRequest) `json:"-"` // We store the handler here
	//Handler HandlerFunc `json:"-"`
	Handler http.HandlerFunc `json:"-"`
}

Route is a route that Harp will proxy to the app

type Server

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

Server is a Harp server

func NewServer

func NewServer() *Server

NewServer creates a new server

func (*Server) HandleFunc

func (s *Server) HandleFunc(path string, handler http.HandlerFunc)

HandleFunc registers a handler for the given path

func (*Server) ListenAndServe

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

ListenAndServe listens on the TCP network address addr and then calls Serve

func (*Server) ListenAndServeWithAutoReconnect

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

ListenAndServeWithAutoReconnect listens on the TCP network address addr and then calls Serve

type Status

type Status struct {
	Online       bool          `json:"online"`
	LastRequest  time.Time     `json:"lastRequest"`
	LastResponse time.Time     `json:"lastResponse"`
	Connected    bool          `json:"connected"`
	AvgLatency   time.Duration `json:"avgLatency"`
}

Status is the status of a route

Jump to

Keyboard shortcuts

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