middleware

package
v0.0.0-...-49721f6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 1, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

  • Description: 使用ffmpeg,用于对视频截取封面

  • Function: 已经实现的功能

  • GetSnapshot() --- 截取第一帧作为视频的封面返回

  • Author: sangs

  • Date: 2023-08-22

  • Description: 用于登录后的jwt鉴权,内部实现了jwt的编解码

  • Function: 已经实现的功能

  • GenerateToken() --- 对id进行JWT编码

  • ParseToken() ------ 对JWT进行解码,并解析可能的错误

  • Author: sangs

  • Date: 2023-08-20

  • Description: Minio对象存储

  • Function: 已经实现的功能

  • MakeBucket() --- 创建Bucket

  • PutToBucket() -- 将服务器接收到的[]byte 文件存入Bucket中

  • InitMinio() ---- 初始化Minio,在项目main函数中调用

  • GetFileURL() --- 通过bucket和filename(有文件类型后缀),返回完整的URL

  • Author: sangs

  • Date: 2023-08-21

Index

Constants

This section is empty.

Variables

View Source
var (
	Client *minio.Client
)

Functions

func ClientMiddleware

func ClientMiddleware(next endpoint.Endpoint) endpoint.Endpoint

ClientMiddleware client middleware print server address 、rpc timeout and connection timeout

func CommonMiddleware

func CommonMiddleware(next endpoint.Endpoint) endpoint.Endpoint

CommonMiddleware common middleware print some rpc info、real request and real response

func GenerateToken

func GenerateToken(id int64) (string, error)

JWT编码

func GetFileURL

func GetFileURL(ctx context.Context, bucketName string, fileName string) (fullURL string, err error)

* Description: 根据bucket和文件名(带文件类型后缀),返回完整的URL * Author: sangs * Date: 2023-08-22>

func GetSnapshot

func GetSnapshot(videoPath string) (buf *bytes.Buffer, err error)

* Description: 将视频的第一帧作为截取下来作为图片返回 * Author: sangs * Date: 2023-08-22

func MakeBucket

func MakeBucket(ctx context.Context, bucketName string)

* Description: 创建Bucket,用于存储视频,一般在 Init 的时候调用即可 * Author: sangs * Date: 2023-08-21

func PutToBucket

func PutToBucket(ctx context.Context, bucketName string, file []byte, filename string, filetype string) (info minio.UploadInfo, err error)

* Description: 将[]byte 格式的文件放入Bucket中 * Author: sangs * Date: 2023-08-21

func PutToBucketByBuf

func PutToBucketByBuf(ctx context.Context, bucketName, filename string, buf *bytes.Buffer) (info minio.UploadInfo, err error)

PutToBucketByBuf put the file into the bucket by *bytes.Buffer

func PutToBucketByFilePath

func PutToBucketByFilePath(ctx context.Context, bucketName, filename, filepath string) (info minio.UploadInfo, err error)

PutToBucketByFilePath put the file into the bucket by filepath

func ServerMiddleware

func ServerMiddleware(next endpoint.Endpoint) endpoint.Endpoint

ServerMiddleware server middleware print client address

Types

type Claims

type Claims struct {
	UserId             int64 `json:"id"` // 为了避免和StandardClaims搞混
	jwt.StandardClaims       // 七个默认字段
}

func ParseToken

func ParseToken(token string) (*Claims, error)

JWT解码

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL