Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = &ErrResponse{ HTTPStatusCode: 404, Body: ErrResponseBody{ StatusText: "Resource not found.", }, }
ErrNotFound is 404
Functions ¶
func FileServer ¶
func FileServer(r chi.Router, path string, root http.FileSystem)
FileServer conveniently sets up a http.FileServer handler to serve static files from a http.FileSystem. Used for Swagger-UI and swagger.json files.
Types ¶
type Config ¶
type Config struct { Address string `mapstructure:"address"` RequestTimeout int `mapstructure:"request_timeout"` }
Config defines webserver configuration
type ErrResponse ¶
type ErrResponse struct { HTTPStatusCode int `json:"-"` // http response status code // in: body Body ErrResponseBody }
ErrResponse renderer type for handling all sorts of errors. swagger:response ErrResponse
func ErrInternal ¶
func ErrInternal(err error) *ErrResponse
ErrInternal returns internal server error
func ErrInvalidRequest ¶
func ErrInvalidRequest(err error) *ErrResponse
ErrInvalidRequest returns failure due to incorrect request parameters or methods
func (*ErrResponse) Render ¶
func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request)
Render forms output for ErrResponse
type ErrResponseBody ¶
type ErrResponseBody struct { // user-level status message StatusText string `json:"status"` // application-level error message, for debugging ErrorText string `json:"error,omitempty"` }
ErrResponseBody is readable output to application/human about error
type FeedRequest ¶
type FeedRequest struct {
Body FeedRequestBody
}
FeedRequest defines update/create request for single feed
type FeedRequestBody ¶
FeedRequestBody defines data of request body
type FeedResponse ¶
type FeedResponse struct { // in: body Body FeedResponseBody }
FeedResponse defines Feed response with Body and any additional headers swagger:response
func NewFeedResponse ¶
func NewFeedResponse(f *entity.Feed) *FeedResponse
NewFeedResponse creates new response struct body for feed
func (*FeedResponse) Render ¶
func (fp *FeedResponse) Render(w http.ResponseWriter, r *http.Request)
Render converts FeedResponseBody to json and sends it to client
type FeedResponseBody ¶
FeedResponseBody is returned on successfull operations to get, create or delete feed.
type FeedsRepository ¶
type FeedsRepository interface { Create(*entity.Feed) error Update(*entity.Feed) error Delete(uuid.UUID) error GetAll() ([]entity.Feed, error) GetByPublicationUUID(uuid.UUID) (*entity.Feed, error) }
FeedsRepository defines repository methods used to manage feeds
type RSSFeedsUpdateProducer ¶
RSSFeedsUpdateProducer provides methods to call update (refresh news from) RSS Feed via messaging subsystem
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server defines HTTP application
func New ¶
func New(serverConfig Config, logger logger.Logger, feedRepository FeedsRepository, messageProducer RSSFeedsUpdateProducer) *Server
New creates new server configuration and configurates middleware
func (*Server) StartAndServe ¶
func (s *Server) StartAndServe()
startAndServe configures routers and starts http server