server

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CSRFMiddleware

func CSRFMiddleware(next http.Handler, trustedOrigins ...string) http.Handler

func ConfigHandler

func ConfigHandler(configPath string) http.HandlerFunc

func ConfigHandlerWithStore

func ConfigHandlerWithStore(store *wsserver.Store) http.HandlerFunc

func DeleteCookie

func DeleteCookie(responseWriter http.ResponseWriter, name string)

func EventsHandler

func EventsHandler(configPath string) http.HandlerFunc

func EventsHandlerWithStore

func EventsHandlerWithStore(store *wsserver.Store) http.HandlerFunc

func IndexHandler

func IndexHandler(configPath string) http.HandlerFunc

func IndexHandlerWithStore

func IndexHandlerWithStore(store *wsserver.Store) http.HandlerFunc

func Run

func Run(addr string, store *wsserver.Store, trustedOrigins []string, token string) error

func SecurityHeaders

func SecurityHeaders(next http.Handler) http.Handler

func SendEventData

func SendEventData(responseWriter http.ResponseWriter, flusher http.Flusher, configPath string) error

SendEventData sends a single Server-Sent Event with the current config.

func SendEventDataFromStore

func SendEventDataFromStore(responseWriter http.ResponseWriter, flusher http.Flusher, store *wsserver.Store) error

func SetSecureCookie

func SetSecureCookie(responseWriter http.ResponseWriter, opts SecureCookieOptions)

SetSecureCookie sets a secure HTTP cookie with configurable options. Uses SameSite=Lax for CSRF protection while allowing top-level navigation.

func SetStrictCookie

func SetStrictCookie(responseWriter http.ResponseWriter, name, value string, maxAge int)

func SetupSSEHeaders

func SetupSSEHeaders(w http.ResponseWriter)

SetupSSEHeaders sets HTTP headers for Server-Sent Events.

func StreamEvents

func StreamEvents(ctx context.Context, responseWriter http.ResponseWriter, flusher http.Flusher, configPath string)

StreamEvents sends Server-Sent Events periodically until context is done.

func StreamEventsFromStore

func StreamEventsFromStore(
	ctx context.Context,
	responseWriter http.ResponseWriter,
	flusher http.Flusher,
	store *wsserver.Store,
)

Types

type SecureCookieOptions

type SecureCookieOptions struct {
	Name     string
	Value    string
	Path     string
	MaxAge   int
	HTTPOnly bool
	Secure   bool
	SameSite http.SameSite
}

Jump to

Keyboard shortcuts

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