api

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrContentNotFound = errors.New("reactions: content not found")

ErrContentNotFound is returned by the ContentResolver when no published content matches the slug. Core translates the content lookup failure to it so this package never imports the content domain.

View Source
var ErrInvalidCursor = errors.New("invalid cursor")

ErrInvalidCursor is returned when the reading-list cursor cannot be parsed.

Functions

func DecodeCursor

func DecodeCursor(cursor string) (int64, int, error)

DecodeCursor inverts EncodeCursor. An empty cursor means the first page.

func EncodeCursor

func EncodeCursor(readLaterAt int64, contentID int) string

EncodeCursor produces the opaque reading-list cursor for the given mark time and content ID.

Types

type ClapRequest

type ClapRequest struct {
	Count *int `json:"count"`
}

ClapRequest is the browser clap payload. Count is a pointer so an omitted field (nil) can be distinguished from an explicit zero: omitted defaults to 1, while an explicit 0 is rejected by the domain's 1..MaxClapsPerRequest validation.

type ContentRef

type ContentRef struct {
	ID int
}

ContentRef is the reaction-relevant projection of a published content item.

type ContentResolver

type ContentResolver func(ctx context.Context, slug string) (ContentRef, error)

ContentResolver resolves a published slug to its reaction-relevant facts. Core satisfies it with a closure over the content service (which cannot be imported here); tests stub it with a func literal.

type ReactionHandler

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

ReactionHandler serves the reaction HTTP surface.

func NewReactionHandler

func NewReactionHandler(
	service ReactionService,
	content ContentResolver,
) *ReactionHandler

NewReactionHandler constructs a ReactionHandler.

func (*ReactionHandler) Clap

Clap adds claps to the reader's row.

func (*ReactionHandler) GetMyReadLater

func (h *ReactionHandler) GetMyReadLater(w http.ResponseWriter, r *http.Request)

GetMyReadLater serves the reader's reading list newest-first.

func (*ReactionHandler) GetPublicReactions

func (h *ReactionHandler) GetPublicReactions(w http.ResponseWriter, r *http.Request)

GetPublicReactions serves clap counts only, with no viewer state.

func (*ReactionHandler) GetReactions

func (h *ReactionHandler) GetReactions(w http.ResponseWriter, r *http.Request)

GetReactions serves counts plus the viewer's own state.

func (*ReactionHandler) MarkReadLater

func (h *ReactionHandler) MarkReadLater(w http.ResponseWriter, r *http.Request)

MarkReadLater marks a post as Read Later.

func (*ReactionHandler) UnmarkReadLater

func (h *ReactionHandler) UnmarkReadLater(w http.ResponseWriter, r *http.Request)

UnmarkReadLater removes the Read Later mark (idempotent).

type ReactionService

type ReactionService interface {
	Clap(
		ctx context.Context,
		contentID int,
		userID int,
		count int,
	) (*reactiondomain.Summary, error)
	SetReadLater(
		ctx context.Context,
		contentID int,
		userID int,
		marked bool,
	) (*reactiondomain.Summary, error)
	GetSummary(
		ctx context.Context,
		contentID int,
		viewerUserID int,
	) (*reactiondomain.Summary, error)
	ListReadLater(
		ctx context.Context,
		userID int,
		afterTime int64,
		afterContentID int,
		limit int,
	) ([]reactiondomain.MarkedItem, reactiondomain.ReadLaterKey, bool, error)
}

ReactionService is the narrow slice of reaction operations this handler depends on. *reactiondomain.Service satisfies it.

type ReadLaterItemResponse

type ReadLaterItemResponse struct {
	ContentID int    `json:"contentId"`
	Slug      string `json:"slug"`
	Title     string `json:"title"`
	Excerpt   string `json:"excerpt"`
	ImageURL  string `json:"imageUrl"`
	Language  string `json:"language"`
	PostType  string `json:"postType"`
	MarkedAt  string `json:"markedAt"`
}

ReadLaterItemResponse is one reading-list entry.

type SummaryResponse

type SummaryResponse struct {
	Claps    int                  `json:"claps"`
	Clappers int                  `json:"clappers"`
	MaxClaps int                  `json:"maxClaps"`
	Viewer   *ViewerStateResponse `json:"viewer,omitempty"`
}

SummaryResponse is the API-facing reaction summary.

type ViewerStateResponse

type ViewerStateResponse struct {
	Claps     int  `json:"claps"`
	ReadLater bool `json:"readLater"`
}

ViewerStateResponse is the reader's own gesture state.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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