Documentation ¶
Index ¶
- func DecodeID(encodedID string) (uint64, error)
- func DecodeIDPadded(encodedID string) (uint64, error)
- func DecodePossibleShortID(shortID string) (uint64, error)
- func EncodeID(id uint) string
- func EncodeIDPadded(id uint) string
- func HTMLTemplate(c *gin.Context, code int, name string, obj gin.H)
- func IsValidShortID(shortID string) bool
- func NullableIsoStringToTime(input *string) (*time.Time, error)
- func TimeToHumanOr(inputTime *time.Time, nilDefault string) string
- type APIShort
- type AppConfig
- type Base64Decoded
- type CreateShort
- type CreateUser
- type LoginUser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeIDPadded ¶
Decode a short id with human friendly padding into a db id
func DecodePossibleShortID ¶
Try to decode a short id from user input into a db id, allowing for human friendly padding
func EncodeIDPadded ¶
Encode a db id into a short id with human friendly padding
func HTMLTemplate ¶
Replaces gin.Context.HTML() to add specific data into them
func IsValidShortID ¶
Check whether given id is a valid ShortID (with or without padding)
Types ¶
type APIShort ¶
type APIShort struct { ShortID string TargetURL string `json:"targetUrl"` VisitCount uint `json:"visitCount,omitempty"` ExpiresAt *time.Time `json:"expiresAt,omitempty"` MaxUses *uint `json:"maxUses,omitempty"` OwnerID *uint `json:"ownerId,omitempty"` CreatedAt time.Time `json:"createdAt"` }
func ShortToAPIShort ¶
type AppConfig ¶
type AppConfig struct { SecretKey Base64Decoded `env:"SECRET_KEY,notEmpty"` SQLitePath string `env:"DB_SQLITE_PATH,notEmpty"` RequireLogin bool `env:"REQUIRE_LOGIN" envDefault:"false"` AllowNewAccounts bool `env:"ALLOW_NEW_ACCOUNTS" envDefault:"true"` }
func (*AppConfig) ParseConfig ¶
Load the config from OS
type Base64Decoded ¶
type Base64Decoded []byte
func (*Base64Decoded) UnmarshalText ¶
func (b *Base64Decoded) UnmarshalText(text []byte) error
type CreateShort ¶
type CreateShort struct { TargetURL string `form:"target-url" json:"targetUrl" binding:"required"` ExpiresAt *string `form:"expires-at" json:"expiresAt"` MaxUses *uint `form:"max-uses" json:"maxUses"` }
func (*CreateShort) GenerateShort ¶
func (s *CreateShort) GenerateShort() db.Short
type CreateUser ¶
Click to show internal directories.
Click to hide internal directories.