controller

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APITokenCreate

type APITokenCreate struct {
	CreateCmd *command.CreateAPIToken
}

APITokenCreate handles POST /v1/tokens to create a new API token.

func (APITokenCreate) ServeHTTP

func (c APITokenCreate) ServeHTTP(w http.ResponseWriter, r *http.Request)

type APITokenCreateRequest

type APITokenCreateRequest struct {
	Name string `json:"name,omitempty"`
}

APITokenCreateRequest is the JSON request body for creating a token.

type APITokenCreateResponse

type APITokenCreateResponse struct {
	ID     string `json:"id"`
	Token  string `json:"token"`
	Prefix string `json:"prefix"`
}

APITokenCreateResponse is the JSON response for a created token.

type APITokenList

type APITokenList struct {
	TokenLister datasources.UserAPITokenLister
}

APITokenList handles GET /v1/tokens to list user's API tokens.

func (APITokenList) ServeHTTP

func (c APITokenList) ServeHTTP(w http.ResponseWriter, r *http.Request)

type APITokenListItem

type APITokenListItem struct {
	ID         string     `json:"id"`
	Prefix     string     `json:"prefix"`
	Name       *string    `json:"name,omitempty"`
	CreatedAt  time.Time  `json:"created_at"`
	LastUsedAt *time.Time `json:"last_used_at,omitempty"`
	ExpiresAt  *time.Time `json:"expires_at,omitempty"`
	Revoked    bool       `json:"revoked"`
}

APITokenListItem represents a token in the list response.

type APITokenListResponse

type APITokenListResponse struct {
	Data []APITokenListItem `json:"data"`
}

APITokenListResponse is the JSON response for listing tokens.

type APITokenRevoke

type APITokenRevoke struct {
	TokenRevoker datasources.APITokenRevoker
}

APITokenRevoke handles DELETE /v1/tokens/{token_id} to revoke a token.

func (APITokenRevoke) ServeHTTP

func (c APITokenRevoke) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ArticleGet

type ArticleGet struct {
	Fetcher     datasources.ArticleFetcher
	CacheMaxAge time.Duration
}

func (ArticleGet) ServeHTTP

func (c ArticleGet) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ArticleRatingSet

type ArticleRatingSet struct {
	Fetcher      datasources.ArticleFetcher
	SetRatingCmd command.Command[command.SetArticleRatingRequest, command.Empty]
	RatingType   domain.UserRatingType
}

func (ArticleRatingSet) ServeHTTP

func (c ArticleRatingSet) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ArticleReadSet

type ArticleReadSet struct {
	Fetcher    datasources.ArticleFetcher
	ReadSetter datasources.ArticleReadSetter
}

func (ArticleReadSet) ServeHTTP

func (c ArticleReadSet) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ArticlesList

type ArticlesList struct {
	Lister interface {
		datasources.LatestArticleLister
		datasources.ArticleFetcher
	}
	CacheMaxAge time.Duration
}

func (ArticlesList) ServeHTTP

func (c ArticlesList) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ArticlesListMetadata

type ArticlesListMetadata struct{}

type ArticlesListResponse

type ArticlesListResponse struct {
	Data     []domain.Article     `json:"data"`
	Metadata ArticlesListMetadata `json:"metadata"`
}

type RSS

type RSS struct {
	FeedHostname    string
	FeedPath        string
	FeedAuthorName  string
	FeedAuthorEmail string
	Dataset         interface {
		datasources.LatestArticleLister
		datasources.ArticleFetcher
	}
	CacheMaxAge time.Duration
}

func (RSS) ServeHTTP

func (c RSS) ServeHTTP(w http.ResponseWriter, r *http.Request)

type RecommendedArticlesList

type RecommendedArticlesList struct {
	Command command.Command[command.RecommendArticlesRequest, []domain.Article]
}

func (RecommendedArticlesList) ServeHTTP

type SemanticSearch added in v0.1.1

type SemanticSearch struct {
	Embedder   datasources.Embedder
	Similarity datasources.SimilarArticlesByVectorLister
	Fetcher    datasources.ArticleFetcher
}

func (SemanticSearch) ServeHTTP added in v0.1.1

func (c SemanticSearch) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SimilarArticlesList

type SimilarArticlesList struct {
	Fetcher     datasources.ArticleFetcher
	Similarity  datasources.SimilarArticleLister
	CacheMaxAge time.Duration
}

func (SimilarArticlesList) ServeHTTP

func (c SimilarArticlesList) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UserArticlesList

type UserArticlesList struct {
	Fetcher    datasources.ArticleFetcher
	ListFunc   UserArticlesLister
	ListEntity string // For error messages, e.g., "unreviewed", "liked", "disliked"
}

UserArticlesList is a generic controller for user-specific article lists.

func (UserArticlesList) ServeHTTP

func (c UserArticlesList) ServeHTTP(w http.ResponseWriter, r *http.Request)

type UserArticlesLister

type UserArticlesLister func(ctx context.Context, userID string, page, pageSize int) ([]string, error)

UserArticlesLister is a function type that lists article IDs for a user with pagination.

Jump to

Keyboard shortcuts

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