Documentation
¶
Index ¶
- Constants
- Variables
- type DatabaseAdapterer
- type DummyHttpAdapter
- type HttpAdapterer
- type HttpHandler
- func (h *HttpHandler) CreatePaste(c *gin.Context)
- func (h *HttpHandler) DeletePasteById(c *gin.Context)
- func (h *HttpHandler) GetAllPastes(c *gin.Context)
- func (h *HttpHandler) GetPasteById(c *gin.Context)
- func (h *HttpHandler) IsPasteContentExistsById(c *gin.Context)
- func (h *HttpHandler) UpdatePasteById(c *gin.Context)
- type MongoStorageAdapter
- func (a *MongoStorageAdapter) CreateOrUpdatePasteContentById(ctx context.Context, id int64, content []byte) error
- func (a *MongoStorageAdapter) CreatePasteContentById(ctx context.Context, id int64, content []byte) error
- func (a *MongoStorageAdapter) DeletePasteContentById(ctx context.Context, id int64) error
- func (a *MongoStorageAdapter) GetPasteContentById(ctx context.Context, id int64) ([]byte, error)
- func (a *MongoStorageAdapter) IsPasteContentExistsById(ctx context.Context, id int64) (bool, error)
- type OuterPaste
- type Paste
- type PostgresDatabaseAdapter
- func (a *PostgresDatabaseAdapter) CreatePaste(ctx context.Context, paste Paste) error
- func (a *PostgresDatabaseAdapter) DeletePasteById(ctx context.Context, id int64) error
- func (a *PostgresDatabaseAdapter) GetAllPastes(ctx context.Context) ([]Paste, error)
- func (a *PostgresDatabaseAdapter) GetPasteById(ctx context.Context, id int64) (Paste, error)
- func (a *PostgresDatabaseAdapter) UpdatePasteById(ctx context.Context, id int64, paste Paste) error
- type Service
- func (s *Service) CreatePaste(ctx context.Context, outerPaste OuterPaste) (string, error)
- func (s *Service) DeletePasteById(ctx context.Context, base64Id string) error
- func (s *Service) GetAllPastes(ctx context.Context) ([]OuterPaste, error)
- func (s *Service) GetPasteById(ctx context.Context, base64Id string) (OuterPaste, error)
- func (s *Service) IsPasteContentExistsById(ctx context.Context, base64Id string) (bool, error)
- func (s *Service) UpdatePasteById(ctx context.Context, base64Id string, outerPaste OuterPaste) error
- type Servicer
- type StorageAdapterer
Constants ¶
View Source
const ( ContentLimitMaxDatabase = 4 //100 << 10 // 100 KiB ContentLimitMaxAnonimous = 10 //1 << 19 // 0.5 MiB ContentLimitMaxTotal = 20 //10 << 20 // 10 MiB )
Variables ¶
View Source
var ( ErrContentOfZeroSize = reqerrors.New(http.StatusBadRequest, "unable to store the content of zero size") ErrContentLargerThanMaxAnonimousLimit = reqerrors.New(http.StatusBadRequest, "unable anonimously to store the content larger than "+strconv.Itoa(ContentLimitMaxAnonimous)+" bytes") ErrContentLargerThanTotalMaxLimit = reqerrors.New(http.StatusBadRequest, "unable to store the content larger than "+strconv.Itoa(ContentLimitMaxTotal)+" bytes") ErrHeaderExpiresAtIsEmpty = reqerrors.New(http.StatusBadRequest, "header 'Expires-At' is empty") ErrPasteNotFound = reqerrors.New(http.StatusNotFound, "paste not found") )
Functions ¶
This section is empty.
Types ¶
type DatabaseAdapterer ¶
type DatabaseAdapterer interface {
CreatePaste(ctx context.Context, paste Paste) error
GetAllPastes(ctx context.Context) ([]Paste, error)
GetPasteById(ctx context.Context, id int64) (Paste, error)
UpdatePasteById(ctx context.Context, id int64, paste Paste) error
DeletePasteById(ctx context.Context, id int64) error
}
type DummyHttpAdapter ¶
type DummyHttpAdapter struct {
// contains filtered or unexported fields
}
func NewDummyHttpAdapter ¶
func NewDummyHttpAdapter(db *database.PostgresDatabase) *DummyHttpAdapter
func (*DummyHttpAdapter) GetGeneratedPasteId ¶
func (a *DummyHttpAdapter) GetGeneratedPasteId(ctx context.Context) (string, error)
type HttpAdapterer ¶
type HttpHandler ¶
type HttpHandler struct {
// contains filtered or unexported fields
}
func NewHttpHandler ¶
func NewHttpHandler(service Servicer) *HttpHandler
func (*HttpHandler) CreatePaste ¶
func (h *HttpHandler) CreatePaste(c *gin.Context)
func (*HttpHandler) DeletePasteById ¶
func (h *HttpHandler) DeletePasteById(c *gin.Context)
func (*HttpHandler) GetAllPastes ¶
func (h *HttpHandler) GetAllPastes(c *gin.Context)
func (*HttpHandler) GetPasteById ¶
func (h *HttpHandler) GetPasteById(c *gin.Context)
func (*HttpHandler) IsPasteContentExistsById ¶
func (h *HttpHandler) IsPasteContentExistsById(c *gin.Context)
func (*HttpHandler) UpdatePasteById ¶
func (h *HttpHandler) UpdatePasteById(c *gin.Context)
type MongoStorageAdapter ¶
type MongoStorageAdapter struct {
// contains filtered or unexported fields
}
func NewMongoStorageAdapter ¶
func NewMongoStorageAdapter(db *database.MongoDatabase) *MongoStorageAdapter
func (*MongoStorageAdapter) CreateOrUpdatePasteContentById ¶
func (*MongoStorageAdapter) CreatePasteContentById ¶
func (*MongoStorageAdapter) DeletePasteContentById ¶
func (a *MongoStorageAdapter) DeletePasteContentById(ctx context.Context, id int64) error
func (*MongoStorageAdapter) GetPasteContentById ¶
func (*MongoStorageAdapter) IsPasteContentExistsById ¶
type OuterPaste ¶
type OuterPaste struct {
Base64Id string `json:"base64Id"`
UserId int64 `json:"userId"`
Content []byte `json:"content"`
CreatedAt string `json:"createdAt"`
ExpiresAt string `json:"expiresAt"`
}
func NewOuterPaste ¶
func NewOuterPaste(c *gin.Context) (OuterPaste, error)
func (OuterPaste) ToPaste ¶
func (p OuterPaste) ToPaste() (Paste, error)
type Paste ¶
func (Paste) ToOuterPaste ¶
func (p Paste) ToOuterPaste() (OuterPaste, error)
type PostgresDatabaseAdapter ¶
type PostgresDatabaseAdapter struct {
// contains filtered or unexported fields
}
func NewPostgresDatabaseAdapter ¶
func NewPostgresDatabaseAdapter(db *database.PostgresDatabase) *PostgresDatabaseAdapter
func (*PostgresDatabaseAdapter) CreatePaste ¶
func (a *PostgresDatabaseAdapter) CreatePaste(ctx context.Context, paste Paste) error
func (*PostgresDatabaseAdapter) DeletePasteById ¶
func (a *PostgresDatabaseAdapter) DeletePasteById(ctx context.Context, id int64) error
func (*PostgresDatabaseAdapter) GetAllPastes ¶
func (a *PostgresDatabaseAdapter) GetAllPastes(ctx context.Context) ([]Paste, error)
func (*PostgresDatabaseAdapter) GetPasteById ¶
func (*PostgresDatabaseAdapter) UpdatePasteById ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService( databaseAdapterer DatabaseAdapterer, storageAdapterer StorageAdapterer, httpAdapterer HttpAdapterer, ) *Service
func (*Service) CreatePaste ¶
func (*Service) DeletePasteById ¶
func (*Service) GetAllPastes ¶
func (s *Service) GetAllPastes(ctx context.Context) ([]OuterPaste, error)
func (*Service) GetPasteById ¶
func (*Service) IsPasteContentExistsById ¶
func (*Service) UpdatePasteById ¶
type Servicer ¶
type Servicer interface {
CreatePaste(ctx context.Context, outerPaste OuterPaste) (string, error)
GetAllPastes(ctx context.Context) ([]OuterPaste, error)
GetPasteById(ctx context.Context, base64Id string) (OuterPaste, error)
UpdatePasteById(ctx context.Context, base64Id string, outerPaste OuterPaste) error
DeletePasteById(ctx context.Context, base64Id string) error
IsPasteContentExistsById(ctx context.Context, base64Id string) (bool, error)
}
type StorageAdapterer ¶
type StorageAdapterer interface {
CreatePasteContentById(ctx context.Context, id int64, content []byte) error
CreateOrUpdatePasteContentById(ctx context.Context, id int64, content []byte) error
GetPasteContentById(ctx context.Context, id int64) ([]byte, error)
DeletePasteContentById(ctx context.Context, id int64) error
IsPasteContentExistsById(ctx context.Context, id int64) (bool, error)
}
Click to show internal directories.
Click to hide internal directories.