api

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORS

func CORS(next http.HandlerFunc) http.HandlerFunc

CORS adds CORS headers to allow cross-origin requests

func GetBanner

func GetBanner(version string) string

GetBanner returns the startup banner with usage information

func GetHelpString

func GetHelpString() string

GetHelpString returns the help string with available cows and moods

func GetUsageString

func GetUsageString() string

GetUsageString returns the usage string

func Health

func Health(version string) http.HandlerFunc

Health handles /health endpoint

func ServeWeb

func ServeWeb() http.Handler

ServeWeb serves the web UI

Types

type Attachment

type Attachment struct {
	Text string `json:"text,omitempty"`
}

Attachment represents a Slack attachment

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents an error response

type HealthResponse

type HealthResponse struct {
	Status  string `json:"status"`
	Version string `json:"version"`
}

HealthResponse represents health check response

type Module

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

Module holds handler dependencies

func NewModule

func NewModule() *Module

NewModule creates a new API handler module with configuration from environment

func (*Module) APICows

func (m *Module) APICows(w http.ResponseWriter, r *http.Request)

APICows handles /api/cows endpoint - lists all available cows

func (*Module) APIMoo

func (m *Module) APIMoo(w http.ResponseWriter, r *http.Request)

APIMoo handles /api/moo endpoint - accepts both JSON and query params

func (*Module) APIMoods

func (m *Module) APIMoods(w http.ResponseWriter, r *http.Request)

APIMoods handles /api/moods endpoint - lists all available moods

func (*Module) Gowsay

func (m *Module) Gowsay(w http.ResponseWriter, r *http.Request)

Gowsay handles Slack /moo command requests

type MooRequest

type MooRequest struct {
	Text    string `json:"text"`
	Cow     string `json:"cow,omitempty"`
	Mood    string `json:"mood,omitempty"`
	Action  string `json:"action,omitempty"`
	Columns int    `json:"columns,omitempty"`
}

MooRequest represents a request to generate cowsay

type MooResponse

type MooResponse struct {
	Output string `json:"output"`
}

MooResponse represents the cowsay output

type SlackResponse

type SlackResponse struct {
	ResponseType string       `json:"response_type,omitempty"`
	Text         string       `json:"text,omitempty"`
	Attachments  []Attachment `json:"attachments,omitempty"`
}

SlackResponse represents a Slack-compatible response

Jump to

Keyboard shortcuts

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