Documentation ¶
Index ¶
- func Must(err error)
- func NewDB(log *zap.Logger, cfg *Config) (*pg.DB, error)
- func NewLog(cnf *Config) (*zap.Logger, error)
- func NewResponseError(statusCode int, message string) error
- type ActionError
- type Actions
- func (a *Actions) GetAllChannels() ([]Channel, *ActionError)
- func (a *Actions) GetChannelById(id uuid.UUID) (*Channel, *ActionError)
- func (a *Actions) GetPostById(id uuid.UUID) (*Post, *ActionError)
- func (a *Actions) GetPostsByChannelOrdered(channelId uuid.UUID, page, pageSize int) ([]Post, *ActionError)
- func (a *Actions) GetPostsByTitle(title string, page, pageSize int) ([]Post, *ActionError)
- func (a *Actions) GetPostsOrdered(page, pageSize int) ([]Post, *ActionError)
- func (a *Actions) SyncChannel(channel Channel) *ActionError
- func (a *Actions) SyncPost(channel *Channel, post *Post, guid string) *ActionError
- type ApiConfig
- type Channel
- type Config
- type DatabaseConfig
- type Environment
- type Flags
- type ImportChannelConfig
- type LoggerConfig
- type Post
- type RequestContext
- func (ctx *RequestContext) AnswerBadRequest(msg string) error
- func (ctx *RequestContext) AnswerInternalError(msg string) error
- func (ctx *RequestContext) AnswerJson(value interface{}) error
- func (ctx *RequestContext) AnswerNotFound(msg string) error
- func (ctx *RequestContext) IntQueryParam(name string) (res int, err error)
- func (ctx *RequestContext) StringQueryParam(name string) (res string, err error)
- func (ctx *RequestContext) UuidParam(name string) (res uuid.UUID, err error)
- func (ctx *RequestContext) WrapActionsError(err *ActionError) error
- type ResponseError
- type ResponseErrorM
- type RssPostId
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewResponseError ¶
Types ¶
type ActionError ¶
type ActionError struct {
// contains filtered or unexported fields
}
func (*ActionError) Error ¶
func (err *ActionError) Error() string
func (*ActionError) IsNotFound ¶
func (err *ActionError) IsNotFound() bool
type Actions ¶
type Actions struct {
// contains filtered or unexported fields
}
func (*Actions) GetAllChannels ¶
func (a *Actions) GetAllChannels() ([]Channel, *ActionError)
func (*Actions) GetChannelById ¶
func (a *Actions) GetChannelById(id uuid.UUID) (*Channel, *ActionError)
func (*Actions) GetPostById ¶
func (a *Actions) GetPostById(id uuid.UUID) (*Post, *ActionError)
func (*Actions) GetPostsByChannelOrdered ¶
func (a *Actions) GetPostsByChannelOrdered(channelId uuid.UUID, page, pageSize int) ([]Post, *ActionError)
page - page to get. starts from 0 pageSize - limit of posts to get.
func (*Actions) GetPostsByTitle ¶
func (a *Actions) GetPostsByTitle(title string, page, pageSize int) ([]Post, *ActionError)
func (*Actions) GetPostsOrdered ¶
func (a *Actions) GetPostsOrdered(page, pageSize int) ([]Post, *ActionError)
page - page to get. starts from 0 pageSize - limit of posts to get.
func (*Actions) SyncChannel ¶
func (a *Actions) SyncChannel(channel Channel) *ActionError
type Channel ¶
type Channel struct { Id uuid.UUID `sql:",pk,type:uuid"` Title string `pg:",notnull"` Image string Description string }
Channel is model representing RSS channel.
type Config ¶
type Config struct { AppName string Environment Environment Logger LoggerConfig Database DatabaseConfig Api ApiConfig Import []ImportChannelConfig }
type DatabaseConfig ¶
type Environment ¶
type Environment string
const ( EnvDevelopment Environment = "Development" EnvProduction Environment = "Production" )
type ImportChannelConfig ¶
type LoggerConfig ¶
type LoggerConfig struct {
Dir string
}
type Post ¶
type Post struct { Id uuid.UUID `sql:",pk,type:uuid"` ChannelId uuid.UUID Channel *Channel `pg:"rel:has-one"` PublicationDate time.Time `pg:",notnull"` // +order key compose index Title string `pg:",notnull"` // +tsvector index Image string Link string Description string `pg:",notnull"` }
Post is model representing RSS item.
type RequestContext ¶
type RequestContext struct {
// contains filtered or unexported fields
}
func (*RequestContext) AnswerBadRequest ¶
func (ctx *RequestContext) AnswerBadRequest(msg string) error
func (*RequestContext) AnswerInternalError ¶
func (ctx *RequestContext) AnswerInternalError(msg string) error
func (*RequestContext) AnswerJson ¶
func (ctx *RequestContext) AnswerJson(value interface{}) error
func (*RequestContext) AnswerNotFound ¶
func (ctx *RequestContext) AnswerNotFound(msg string) error
func (*RequestContext) IntQueryParam ¶
func (ctx *RequestContext) IntQueryParam(name string) (res int, err error)
IntQueryParam returns parsed int from request query params. name - query variable name.
func (*RequestContext) StringQueryParam ¶
func (ctx *RequestContext) StringQueryParam(name string) (res string, err error)
StringQueryParam returns string from request query params. name - query variable name.
func (*RequestContext) UuidParam ¶
func (ctx *RequestContext) UuidParam(name string) (res uuid.UUID, err error)
UuidParam returns parsed id in UUID format from request uri. name - uri context variable name.
func (*RequestContext) WrapActionsError ¶
func (ctx *RequestContext) WrapActionsError(err *ActionError) error
type ResponseError ¶
type ResponseError struct {
// contains filtered or unexported fields
}
func (*ResponseError) Error ¶
func (e *ResponseError) Error() string
type ResponseErrorM ¶
type ResponseErrorM struct {
Error string `json:"error"`
}
type RssPostId ¶
type RssPostId struct { Guid string `pg:",notnull"` ChannelId uuid.UUID `sql:",type:uuid"` Channel *Channel `pg:"rel:has-one"` PostId uuid.UUID `sql:",type:uuid"` Post *Post `pg:"rel:has-one"` }
RssPostId is model of mapping guid from RSS item to PostId
Click to show internal directories.
Click to hide internal directories.