40 lines
1.4 KiB
Go
40 lines
1.4 KiB
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// A request to the store will be this json struct.
|
|
type Response struct {
|
|
DelKey string `json:"delkey"` // The id to use when delete a paste
|
|
Expiry string `json:"expiry"` // The date when post expires
|
|
Extra string `json:"extra"` // Extra output from the highlight-wrapper
|
|
Id string `json:"id"` // The id of the paste
|
|
Lang string `json:"lang"` // Specified language
|
|
Paste string `json:"paste"` // The eactual paste data
|
|
Sha1 string `json:"sha1"` // The sha1 of the paste
|
|
Size int `json:"size"` // The length of the paste
|
|
Status string `json:"status"` // A custom status message
|
|
Style string `json:"style"` // Specified style
|
|
Title string `json:"title"` // The title of the paste
|
|
}
|
|
|
|
type Pastes struct {
|
|
Response []Response
|
|
}
|
|
|
|
type Store interface {
|
|
GetUserKey(ctx context.Context, email string) (string, error)
|
|
GetUserPastes(ctx context.Context, userKey string) (*Pastes, error)
|
|
GetPaste(ctx context.Context, pasteId string) (*Response, error)
|
|
|
|
SavePaste(ctx context.Context, title string, data string, expiry time.Duration, userKey string) (*Response, error)
|
|
|
|
ForceDelPaste(ctx context.Context, pasteId string) error
|
|
DelPaste(ctx context.Context, pasteId, delKey string) error
|
|
|
|
HasAccount(ctx context.Context, email string) ([]byte, error)
|
|
RegisterUser(ctx context.Context, email string, hashpass []byte) error
|
|
}
|