Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Decode(value string) (string, error)
- func Base64DecodeToByte(value string) ([]byte, error)
- func Base64Encode(value string) string
- func Base64EncodeByte(value []byte) string
- func CreateJWT[T interface{}](secret string, claims JWTClaims[T]) (string, error)
- func Decrypt(secret, value string) (string, error)
- func Encrypt(secret, value string) (string, error)
- func GetClientIP(r *http.Request) string
- func LogError(msg string, err error)
- func PackError(err error) error
- func ParseJWT[T interface{}](secretFunc jwt.Keyfunc, encodedToken string, claims *JWTClaims[T], ...) (*jwt.Token, error)
- func UnmarshalJSON(statusCode int, body []byte, v interface{}) error
- type APIError
- type BasicAuth
- type Error
- type ErrorCode
- type ErrorType
- type JWTClaims
- type MagnetLink
- type StoreError
- type StremThruError
- type UpstreamError
Constants ¶
View Source
const EncryptionFormat = "AES-GCM-256"
Variables ¶
View Source
var HasVideoExtension = func() func(filename string) bool { videoExtensions := map[string]bool{ ".3g2": true, ".3gp": true, ".amv": true, ".asf": true, ".avi": true, ".drc": true, ".f4a": true, ".f4b": true, ".f4p": true, ".f4v": true, ".flv": true, ".gif": true, ".gifv": true, ".m2ts": true, ".m2v": true, ".m4p": true, ".m4v": true, ".mk3d": true, ".mkv": true, ".mng": true, ".mov": true, ".mp2": true, ".mp4": true, ".mpe": true, ".mpeg": true, ".mpg": true, ".mpv": true, ".mxf": true, ".nsv": true, ".ogg": true, ".ogm": true, ".ogv": true, ".qt": true, ".rm": true, ".rmvb": true, ".roq": true, ".svi": true, ".ts": true, ".webm": true, ".wmv": true, ".yuv": true, } return func(filename string) bool { _, found := videoExtensions[strings.ToLower(filepath.Ext(filename))] return found } }()
Functions ¶
func Base64Decode ¶
func Base64DecodeToByte ¶
func Base64Encode ¶
func Base64EncodeByte ¶
func GetClientIP ¶
func UnmarshalJSON ¶
Types ¶
type APIError ¶
type APIError struct {
// contains filtered or unexported fields
}
func NewAPIError ¶
type BasicAuth ¶
func ParseBasicAuth ¶
type Error ¶
type Error struct { Type ErrorType `json:"type"` Code ErrorCode `json:"code,omitempty"` Msg string `json:"message"` Method string `json:"method,omitempty"` Path string `json:"path,omitempty"` StatusCode int `json:"status_code,omitempty"` StoreName string `json:"store_name,omitempty"` UpstreamCause error `json:"__upstream_cause__,omitempty"` Cause error `json:"__cause__,omitempty"` }
func (*Error) GetStatusCode ¶
func (*Error) Send ¶
func (e *Error) Send(w http.ResponseWriter)
type ErrorCode ¶
type ErrorCode string
const ( ErrorCodeUnknown ErrorCode = "UNKNOWN" ErrorCodeBadGateway ErrorCode = "BAD_GATEWAY" ErrorCodeBadRequest ErrorCode = "BAD_REQUEST" ErrorCodeConflict ErrorCode = "CONFLICT" ErrorCodeForbidden ErrorCode = "FORBIDDEN" ErrorCodeGone ErrorCode = "GONE" ErrorCodeInternalServerError ErrorCode = "INTERNAL_SERVER_ERROR" ErrorCodeMethodNotAllowed ErrorCode = "METHOD_NOT_ALLOWED" ErrorCodeNotFound ErrorCode = "NOT_FOUND" ErrorCodeNotImplemented ErrorCode = "NOT_IMPLEMENTED" ErrorCodePaymentRequired ErrorCode = "PAYMENT_REQUIRED" ErrorCodeProxyAuthenticationRequired ErrorCode = "PROXY_AUTHENTICATION_REQUIRED" ErrorCodeTooManyRequests ErrorCode = "TOO_MANY_REQUESTS" ErrorCodeUnprocessableEntity ErrorCode = "UNPROCESSABLE_ENTITY" ErrorCodeUnsupportedMediaType ErrorCode = "UNSUPPORTED_MEDIA_TYPE" ErrorCodeStoreLimitExceeded ErrorCode = "STORE_LIMIT_EXCEEDED" ErrorCodeStoreMagnetInvalid ErrorCode = "STORE_MAGNET_INVALID" ErrorCodeStoreNameInvalid ErrorCode = "STORE_NAME_INVALID" )
type JWTClaims ¶
type JWTClaims[T interface{}] struct { jwt.RegisteredClaims Data *T `json:"data,omitempty"` }
type MagnetLink ¶
type MagnetLink struct { Hash string // xt - exact topic Link string Name string // dn - display name Trackers []string // tr - address tracker }
func ParseMagnetLink ¶
func ParseMagnetLink(value string) (MagnetLink, error)
type StoreError ¶
type StoreError struct {
// contains filtered or unexported fields
}
func NewStoreError ¶
func NewStoreError(msg string) *StoreError
type StremThruError ¶
type StremThruError interface { Pack() GetStatusCode() int GetError() *Error Send(w http.ResponseWriter) }
type UpstreamError ¶
type UpstreamError struct {
// contains filtered or unexported fields
}
func NewUpstreamError ¶
func NewUpstreamError(msg string) *UpstreamError
Click to show internal directories.
Click to hide internal directories.