Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrSecretOutdated secret in not valid anymore ErrSecretOutdated = errors.New("secret isn't valid anymore") )
Functions ¶
Types ¶
type Database ¶
type Database interface { GetSecret(hash string) (*models.Secret, error) CreateSecret(hash string, s models.Secret) error DeleteSecret(hash string) error UpdateSecret(hash string, s models.Secret) error }
Database is a database layer interface
type SecretHandler ¶
type SecretHandler struct {
// contains filtered or unexported fields
}
SecretHandler is a REST API handler for secret service
func NewSecretHandler ¶
func NewSecretHandler(db Database) *SecretHandler
NewSecretHandler creates a new API handler
func (*SecretHandler) GetSecret ¶
func (h *SecretHandler) GetSecret(c *gin.Context)
GetSecret returns a secret if possible.
It tries to get a secret by hash, if found, checks view counter and TTL. If any of checks fails, the method will delete this secret as expired. Otherwise, it will decrement view counter and return the secret.
func (*SecretHandler) PostSecret ¶
func (h *SecretHandler) PostSecret(c *gin.Context)
PostSecret creates a new secret.
The method verifies incoming data and creates a new encrypted secret in the database.
Click to show internal directories.
Click to hide internal directories.