mobileapi

package
v0.0.0-...-b17c1e0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SupportedProviders map[string]interface{} = map[string]interface{}{"rss": nil}

SupportedProviders contains a list of "type" of providers that are supported by the aggregator. This map could later on use a factory function to create an instance of associated provider, instead of the placeholder `interface{}`

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error,omitempty"`
}

ErrorResponse is returned to requests that result in some error state such as bad request or internal server error

type Handler

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

Handler implements HTTP API

func NewHandler

func NewHandler(service Service, addr string) (Handler, error)

NewHandler constructs a new instance of Handler

func (*Handler) HandleGetArticles

func (h *Handler) HandleGetArticles() http.HandlerFunc

HandleGetArticles returns articles matching specified criteria

func (*Handler) HandlePing

func (h *Handler) HandlePing() http.HandlerFunc

HandlePing is a simple handle to enable clients to test connectivity

func (*Handler) HandlePostProvider

func (h *Handler) HandlePostProvider() http.HandlerFunc

HandlePostProvider saves provider information for use by the aggregator component

func (*Handler) Start

func (h *Handler) Start() error

Start starts the underlying http server

func (*Handler) Stop

func (h *Handler) Stop() error

Stop stops the underlying http server

type Service

type Service interface {
	GetArticles(ctx context.Context, offset, count int, category, provider []string) ([]storage.Article, error)
	SaveProvider(ctx context.Context, provider storage.Provider) (string, error)
}

Service defines the functionality required by the mobile-api

type ServiceImpl

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

ServiceImpl implements the domain logic for the mobile api

func NewService

func NewService(articleRepo storage.ArticleRepository, providerRepo storage.ProviderRepository, msgBus *nats.Conn) (*ServiceImpl, error)

NewService returns a new instance of the service mobile api service domain logic implementation

func (*ServiceImpl) GetArticles

func (s *ServiceImpl) GetArticles(ctx context.Context, offset, count int, category, provider []string) ([]storage.Article, error)

GetArticles retrieves a list of articles from underlying storage. Filter parameters can be used to reduce the results

func (*ServiceImpl) SaveProvider

func (s *ServiceImpl) SaveProvider(ctx context.Context, provider storage.Provider) (string, error)

SaveProvider saves a provider to underlying storage

Jump to

Keyboard shortcuts

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