Documentation
¶
Index ¶
- Variables
- func DecodeCursor(cursor string) (int64, int, error)
- func EncodeCursor(readLaterAt int64, contentID int) string
- type ClapRequest
- type ContentRef
- type ContentResolver
- type ReactionHandler
- func (h *ReactionHandler) Clap(w http.ResponseWriter, r *http.Request)
- func (h *ReactionHandler) GetMyReadLater(w http.ResponseWriter, r *http.Request)
- func (h *ReactionHandler) GetPublicReactions(w http.ResponseWriter, r *http.Request)
- func (h *ReactionHandler) GetReactions(w http.ResponseWriter, r *http.Request)
- func (h *ReactionHandler) MarkReadLater(w http.ResponseWriter, r *http.Request)
- func (h *ReactionHandler) UnmarkReadLater(w http.ResponseWriter, r *http.Request)
- type ReactionService
- type ReadLaterItemResponse
- type SummaryResponse
- type ViewerStateResponse
Constants ¶
This section is empty.
Variables ¶
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.
var ErrInvalidCursor = errors.New("invalid cursor")
ErrInvalidCursor is returned when the reading-list cursor cannot be parsed.
Functions ¶
func DecodeCursor ¶
DecodeCursor inverts EncodeCursor. An empty cursor means the first page.
func EncodeCursor ¶
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 ¶
func (h *ReactionHandler) Clap(w http.ResponseWriter, r *http.Request)
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 ¶
ViewerStateResponse is the reader's own gesture state.