webhook

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package webhook implements a local HTTP catch-all server for inspecting outbound webhook payloads. It records every inbound request, formats the body as pretty-printed JSON where possible, and exposes requests over a channel so the TUI can live-render them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendRequest

func SendRequest(p *tea.Program, r Request)

SendRequest is a helper for goroutines that need to push a request into the Bubble Tea program from outside the model.

Types

type Model

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

Model is the Bubble Tea model for the webhook catch TUI.

func NewModel

func NewModel(webhookURL, publicURL string) Model

NewModel creates a new TUI model.

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type Request

type Request struct {
	Time       time.Time
	Method     string
	Path       string
	UserAgent  string
	Headers    map[string]string
	Body       string // raw body
	BodyJSON   string // pretty-printed JSON, empty if not JSON
	Duration   time.Duration
	StatusCode int // always 200 — we always accept
}

Request captures a single inbound request to the catch server.

type Server

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

Server is the webhook catch server.

func New

func New(port int) *Server

New creates a new catch server on the given port. Received requests are sent to the returned channel.

func (*Server) Requests

func (s *Server) Requests() <-chan Request

Requests returns the channel of captured requests.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown gracefully stops the server.

func (*Server) Start

func (s *Server) Start() (string, error)

Start begins listening on the configured port. It returns the actual bound address (useful when port 0 was requested for OS-assigned port).

Jump to

Keyboard shortcuts

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