api

package
v0.0.0-...-9d48049 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: Unlicense Imports: 11 Imported by: 0

Documentation

Overview

Package api lite-reader

Documentation of the lite-reader service. It is a service to schedule webhooks.

Schemes: http
BasePath: /
Version: 1.0.0
Host: lite-reader

Consumes:
- application/json

Produces:
- application/json

swagger:meta

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(w http.ResponseWriter, details string) error

BadRequest writes the BadRequest error details in json with the provided details

func InternalError

func InternalError(w http.ResponseWriter, details string) error

InternalError writes the error details in json with the provided details

func InvalidParams

func InvalidParams(w http.ResponseWriter, details string) error

InvalidParams writes the UnprocessableEntity error details in json with the provided details

func NotFound

func NotFound(w http.ResponseWriter, details string) error

NotFound writes the NotFound error details in json with the provided details

Types

type AddFeedRequest

type AddFeedRequest struct {
	URL string `json:"url"`
}

func (*AddFeedRequest) Validate

func (r *AddFeedRequest) Validate() error

type AddFeedResponse

type AddFeedResponse struct {
	ID          int       `json:"id"`
	Title       string    `json:"title"`
	Desc        string    `json:"desc"`
	Link        string    `json:"link"`
	URL         string    `json:"url"`
	UpdatedAt   time.Time `json:"updated_at"`
	Lang        string    `json:"lang"`
	UnreadCount int       `json:"unread_count"`
}

type FeedService

type FeedService interface {
	AddFeed(command *feed.AddFeedCommand) (*feed.Feed, error)
	ListFeeds() ([]*feed.Feed, error)
	FetchItems(int) ([]*item.Item, error)
	DeleteFeed(command *feed.DeleteFeedCommand) error
}

type GetItemsCountResponse

type GetItemsCountResponse struct {
	Count int `json:"count"`
}

type GetUnreadItemsResponse

type GetUnreadItemsResponse struct {
	Items []*ItemResponse `json:"items"`
}

type ItemResponse

type ItemResponse struct {
	ID        int       `json:"id"`
	Title     string    `json:"title"`
	Desc      string    `json:"desc"`
	Link      string    `json:"link"`
	IsNew     bool      `json:"is_new"`
	Starred   bool      `json:"starred"`
	Timestamp time.Time `json:"timestamp"`
}

type ItemService

type ItemService interface {
	GetUnreadItems() ([]*item.Item, error)
	GetStarredItems() ([]*item.Item, error)
	GetFeedItems(*item.GetFeedItemsCommand) ([]*item.Item, error)
	UpsertItems(command *item.UpsertItemsCommand) error
	UpdateItem(*item.UpdateItemCommand) error
	ReadFeedItems(*item.ReadFeedItemsCommand) error
	UnreadFeedItems(*item.UnreadFeedItemsCommand) error
	GetStarredItemsCount() (int, error)
	GetUnreadItemsCount() (int, error)
	DeleteFeedItems(*item.DeleteFeedItemsCommand) error
}

type JSONError

type JSONError struct {
	// Code of the error
	Code int `json:"code"`
	// Details of the error
	Details string `json:"details"`
}

JSONError is used to return http errors encoded in json

type ListFeedResponse

type ListFeedResponse []*AddFeedResponse

type Router

type Router struct {
	http.Handler
	// contains filtered or unexported fields
}

Router handles http requests

func New

func New(itemService ItemService, feedService FeedService) (*Router, error)

New creates a new handler to handle http requests

type UpdateItemRequest

type UpdateItemRequest struct {
	Starred bool `json:"starred"`
	IsNew   bool `json:"is_new"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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