app

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPListenAndServe = http.ListenAndServe

Indirections for easier testing (do not change runtime behavior)

View Source
var HTTPServe = http.Serve
View Source
var NgrokListen = func(ctx context.Context, epOpts []config.HTTPEndpointOption, connectOpts []ngrok.ConnectOption) (ListenerWithURL, error) {
	return ngrok.Listen(ctx, config.HTTPEndpoint(epOpts...), connectOpts...)
}
View Source
var ServeLocalFunc = func(addr string, mux http.Handler) error {
	return HTTPListenAndServe(addr, mux)
}

serveLocalFunc starts a local HTTP server. Overridable in tests.

View Source
var ServeNgrokFunc = func(ctx context.Context, epOpts []config.HTTPEndpointOption, connectOpts []ngrok.ConnectOption, mux http.Handler) error {
	ln, err := NgrokListen(ctx, epOpts, connectOpts)
	if err != nil {
		return err
	}
	log.Printf("%s[INFO]%s Public URL: %s", colorGreen, colorReset, ln.URL())
	log.Printf("%s[INFO]%s All incoming requests will be printed below. Press Ctrl+C to stop.", colorGreen, colorReset)
	return HTTPServe(ln, mux)
}

serveNgrokFunc starts an ngrok listener and serves HTTP on it. Overridable in tests.

Functions

func ColorMethod

func ColorMethod(m string) string

func LoadDotEnv

func LoadDotEnv(path string)

func Run

func Run(opts Options) error

Run contains the main logic, extracted for testability.

func SaveEnvVar

func SaveEnvVar(path, key, value string) error

saveEnvVar upserts a KEY=VALUE line into the given .env file.

func TryPrettyJSON

func TryPrettyJSON(b []byte) (string, bool)

func WebhookHandler

func WebhookHandler(w http.ResponseWriter, r *http.Request)

Types

type ListenerWithURL

type ListenerWithURL interface {
	net.Listener
	URL() string
}

type Options

type Options struct {
	Host        string
	Port        int
	Tunnel      bool
	NgrokToken  string
	NgrokRegion string
	NgrokDomain string
}

Options contains runtime options for Run.

Jump to

Keyboard shortcuts

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