http

package
v1.14.4 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StaticPath      = "/static"
	PodcastPath     = "/podcast"
	MediaPath       = "/media"
	PodcastFeedName = "feed.rss"
)
View Source
const (
	ContentTypeHeader  = "Content-Type"
	ContentTypeXML     = "application/xml; charset=utf-8"
	ContentTypeTextXML = "text/xml; charset=utf-8"
	ContentTypeJSON    = "application/json; charset=utf-8"
	ContentTypeHTML    = "text/html"
)

Variables

This section is empty.

Functions

func GetCachingMiddleware added in v1.13.2

func GetCachingMiddleware(cacheStore CacheStore) func(http.Handler) http.Handler

func GetLoggingMiddleware added in v1.13.2

func GetLoggingMiddleware(logger loggerrific.Logger) func(http.Handler) http.Handler

func SendJSON

func SendJSON(writer http.ResponseWriter, status int, p any)

func SendJSONError

func SendJSONError(w http.ResponseWriter, status int, err error)

func Serve

func Serve(handler http.Handler, port int, logger loggerrific.Logger) error

func SevereRateLimitMiddleware

func SevereRateLimitMiddleware(next http.Handler) http.Handler

func TimeoutMiddleware

func TimeoutMiddleware(next http.Handler) http.Handler

Types

type AudiobooksPodcastService

type AudiobooksPodcastService interface {
	WriteAllAudiobooksFeed(context.Context, io.Writer) error
	WriteGenreAudiobookFeed(context.Context, audiobooks.Genre, io.Writer) error
	WriteAuthorAudiobookFeed(context.Context, string, io.Writer) (bool, error)
	WriteNarratorAudiobookFeed(context.Context, string, io.Writer) (bool, error)
	WriteTagAudiobookFeed(context.Context, string, io.Writer) (bool, error)
	UpdateFeeds(context.Context) error
	IsReady(ctx context.Context) bool
}

type CacheStore added in v1.11.0

type CacheStore interface {
	Get(key uint64) ([]byte, bool)
	Set(key uint64, content []byte, expiration time.Time)
	Release(key uint64)
	ReleaseAll()
	GetTTL() time.Duration
}

type Handler

type Handler struct {
	*chi.Mux
	PodcastService AudiobooksPodcastService

	CacheStore CacheStore
	Log        loggerrific.Logger
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(podcastService AudiobooksPodcastService, mediaRoot string, opts ...HandlerOption) *Handler

type HandlerOption

type HandlerOption func(h *Handler)

func WithCacheStore added in v1.13.2

func WithCacheStore(cacheStore CacheStore) HandlerOption

func WithLogger added in v1.13.2

func WithLogger(logger loggerrific.Logger) HandlerOption

func WithVersion

func WithVersion(version string) HandlerOption

type Middlewares

type Middlewares struct {
	loggerrific.Logger
	CacheStore
}

type Payload

type Payload map[string]any

Jump to

Keyboard shortcuts

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