Documentation ¶
Index ¶
- Variables
- func MapToBucket(baseURL string, m map[string]string) *[]BucketItem
- type BucketItem
- type URLID
- type URLShortenCorrelatedRequest
- type URLShortenRequest
- type URLShortener
- func (a *URLShortener) Batch(ctx context.Context, request *pb.ShortBatchRequest) (*pb.ShortBatchResponse, error)
- func (a *URLShortener) CreateBatch(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) CreateJSONShorten(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) CreateShortURL(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) DBConnect(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) Delete(ctx context.Context, request *pb.DeleteRequest) (*emptypb.Empty, error)
- func (a *URLShortener) DeleteUrls(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) Expand(ctx context.Context, request *pb.ExpandRequest) (*pb.ExpandResponse, error)
- func (a *URLShortener) GetStats(res http.ResponseWriter, _ *http.Request)
- func (a *URLShortener) GetUrlsByUser(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) GetUserBucket(ctx context.Context, request *pb.GetUserBucketRequest) (*pb.GetUserBucketResponse, error)
- func (a *URLShortener) ReadOriginalURL(res http.ResponseWriter, req *http.Request)
- func (a *URLShortener) Shorten(ctx context.Context, request *pb.ShortRequest) (*pb.ShortResponse, error)
- func (a *URLShortener) Stats(ctx context.Context, empty *emptypb.Empty) (*pb.StatResponse, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrLinkIsDeleted = errors.New("ссылка удалена") ErrLinkNotFound = errors.New("ссылка не найдена") )
Functions ¶
func MapToBucket ¶
func MapToBucket(baseURL string, m map[string]string) *[]BucketItem
MapToBucket создает корзину ссылок из `map[string]string`
Types ¶
type BucketItem ¶
type URLShortenCorrelatedRequest ¶
type URLShortenCorrelatedRequest struct {}
URLShortenCorrelatedRequest представляет собой структуру, в которую требуется дериализовать список ссылок для сокращения [
{ "correlation_id": "4444", "original_url": "https://..." }, ...
]
type URLShortenRequest ¶
type URLShortenRequest struct {
URL string `json:"url"`
}
URLShortenRequest represents JSON {"url":"<some_url>"}
type URLShortener ¶
type URLShortener struct { pb.UnimplementedShortenerServer // contains filtered or unexported fields }
func NewURLShortener ¶
func NewURLShortener(base string, repo service.URLShortenerService) *URLShortener
NewURLShortener создает URLShortener и инициализирует его адресом, по которому будут доступны методы, и репозиторием хранения ссылок.
func (*URLShortener) Batch ¶
func (a *URLShortener) Batch(ctx context.Context, request *pb.ShortBatchRequest) (*pb.ShortBatchResponse, error)
func (*URLShortener) CreateBatch ¶
func (a *URLShortener) CreateBatch(res http.ResponseWriter, req *http.Request)
CreateBatch Хендлер создания нескольких ссылок
func (*URLShortener) CreateJSONShorten ¶
func (a *URLShortener) CreateJSONShorten(res http.ResponseWriter, req *http.Request)
CreateJSONShorten хендлер создания ссылки из json
func (*URLShortener) CreateShortURL ¶
func (a *URLShortener) CreateShortURL(res http.ResponseWriter, req *http.Request)
CreateShortURL хендлер создания короткой ссылки
func (*URLShortener) DBConnect ¶
func (a *URLShortener) DBConnect(res http.ResponseWriter, req *http.Request)
DBConnect хендлер проверки подключения к БД
func (*URLShortener) Delete ¶
func (a *URLShortener) Delete(ctx context.Context, request *pb.DeleteRequest) (*emptypb.Empty, error)
func (*URLShortener) DeleteUrls ¶
func (a *URLShortener) DeleteUrls(res http.ResponseWriter, req *http.Request)
DeleteUrls хендлер удаления ссылок
func (*URLShortener) Expand ¶
func (a *URLShortener) Expand(ctx context.Context, request *pb.ExpandRequest) (*pb.ExpandResponse, error)
func (*URLShortener) GetStats ¶
func (a *URLShortener) GetStats(res http.ResponseWriter, _ *http.Request)
func (*URLShortener) GetUrlsByUser ¶
func (a *URLShortener) GetUrlsByUser(res http.ResponseWriter, req *http.Request)
GetUrlsByUser хендлер получения списка ссылок пользователя
func (*URLShortener) GetUserBucket ¶
func (a *URLShortener) GetUserBucket(ctx context.Context, request *pb.GetUserBucketRequest) (*pb.GetUserBucketResponse, error)
func (*URLShortener) ReadOriginalURL ¶
func (a *URLShortener) ReadOriginalURL(res http.ResponseWriter, req *http.Request)
ReadOriginalURL хендлер получения оригинальной ссылки
func (*URLShortener) Shorten ¶
func (a *URLShortener) Shorten(ctx context.Context, request *pb.ShortRequest) (*pb.ShortResponse, error)
func (*URLShortener) Stats ¶
func (a *URLShortener) Stats(ctx context.Context, empty *emptypb.Empty) (*pb.StatResponse, error)