This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ARG GO_VERSION=1.12 | |
| FROM golang:${GO_VERSION}-alpine AS builder | |
| RUN apk add --no-cache ca-certificates git tzdata | |
| WORKDIR /src | |
| COPY ./go.mod ./go.sum ./ | |
| RUN go mod download |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package controllers | |
| import ( | |
| "net/http" | |
| "strconv" | |
| "github.com/gin-gonic/gin" | |
| ) | |
| // NewsController <controller> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package crawler | |
| import ( | |
| "time" | |
| ) | |
| // NewsCrawler <interface> | |
| // is used to describe news crawler class instance | |
| type NewsCrawler interface { | |
| Run() []models.News |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package server | |
| import ( | |
| ) | |
| // Init <function> | |
| // is used to initialize server and all the corresponding services such as DB, Utils, Workers | |
| func Init() { | |
| // utils |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package db | |
| import ( | |
| "go.mongodb.org/mongo-driver/bson" | |
| "go.mongodb.org/mongo-driver/mongo/options" | |
| ) | |
| const ( | |
| newsCollection = "news" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package db | |
| import ( | |
| "go.mongodb.org/mongo-driver/bson" | |
| ) | |
| const ( | |
| newsSourcesCollection = "news_sources" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package db | |
| // FillSeedsInformation <function> | |
| // is used to fill information that needed before usage of news endpoint | |
| func (s Service) FillSeedsInformation() { | |
| s.fillNewsSources() | |
| s.fillNewsTypes() | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package db | |
| import ( | |
| "context" | |
| "fmt" | |
| "time" | |
| "go.mongodb.org/mongo-driver/mongo" | |
| "go.mongodb.org/mongo-driver/mongo/options" | |
| "go.mongodb.org/mongo-driver/mongo/readpref" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package crawler | |
| import ( | |
| "time" | |
| ) | |
| // NewsCrawler <interface> | |
| // is used to describe news crawler class instance | |
| type NewsCrawler interface { | |
| Run() []models.News |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package utils | |
| import ( | |
| "crypto/sha1" | |
| "encoding/hex" | |
| ) | |
| // MakeHash <function> | |
| // is used to create hash from string | |
| func MakeHash(s string) string { |