utils

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(n int) int

int 절대값 구하기

func AskImageDescription

func AskImageDescription(path string) (string, error)

OpenAI의 API를 이용해서 사진에 대한 설명 가져오기

func CheckCommentParameters

func CheckCommentParameters(c fiber.Ctx) (models.CommentWriteParameter, error)

새 댓글 및 답글 작성 시 파라미터 체크

func CheckWriteParameters

func CheckWriteParameters(c fiber.Ctx) (models.EditorWriteParameter, error)

글 작성/수정 시 파라미터 검사 및 타입 변환

func ConvJsonString

func ConvJsonString(value interface{}) (string, error)

구조체를 JSON 형식의 문자열로 변환

func ConvTimestamp

func ConvTimestamp(timestamp uint64) string

Unix timestamp 형식의 숫자를 YYYY:mm:dd HH:ii:ss 형태로 변경

func ConvUnixMilli

func ConvUnixMilli(timeStr string) uint64

YYYY:mm:dd HH:ii:ss 형태의 시간 문자를 Unix timestamp로 변경

func CopyFile

func CopyFile(destPath string, file multipart.File) error

대상 경로에 파일 복사하기

func CutString

func CutString(s string, max int) string

(한글 포함) 문자열 안전하게 자르기

func DownloadImage

func DownloadImage(imageUrl string, outputPath string, width uint) error

URL로부터 이미지 경로를 받아서 지정된 크기로 줄이고 .webp 형식으로 저장

func EncodeImage

func EncodeImage(path string) (string, error)

이미지를 Base64로 인코딩해서 문자열로 반환

func Err

func Err(c fiber.Ctx, msg string, code models.Code) error

에러 메시지에 대한 응답

func Escape

func Escape(raw string) string

HTML 문자열을 이스케이프

func ExtractExif

func ExtractExif(imagePath string) models.BoardExif

EXIF 정보 추출

func ExtractUserUid

func ExtractUserUid(authorization string) int

헤더로 넘어온 Authorization 문자열 추출해서 사용자 고유 번호 반환

func GenerateAccessToken

func GenerateAccessToken(userUid uint, hours int) (string, error)

액세스 토큰 생성하기 (유효시간 기입 필요)

func GenerateRefreshToken

func GenerateRefreshToken(days int) (string, error)

리프레시 토큰 생성하기 (유효일자 기입 필요)

func GetContentStatus

func GetContentStatus(isNotice bool, isSecret bool) models.Status

게시글/댓글 상태값 반환

func GetFileSize

func GetFileSize(path string) uint

파일의 크기 반환

func GetHashedString

func GetHashedString(input string) string

주어진 문자열을 sha256 알고리즘으로 변환

func IsImage

func IsImage(path string) bool

주어진 파일 경로가 이미지 파일인지 아닌지 확인하기

func IsValidEmail

func IsValidEmail(email string) bool

아이디가 이메일 형식에 부합하는지 확인

func MakeSavePath

func MakeSavePath(target models.UploadCategory) (string, error)

파일 저장 경로 만들기 (맨 앞 `.` 은 DB에 넣을 때 빼줘야함)

func MakeTempJpeg

func MakeTempJpeg(path string) (string, error)

이미지 비전용으로 잠시 사용하고 삭제할 고압축 미니 썸네일 생성

func OAuth2ExchangeToken

func OAuth2ExchangeToken(c fiber.Ctx, cfg oauth2.Config) (*oauth2.Token, error)

상태 검사 및 토큰 교환 후 토큰 반환

func Ok

func Ok(c fiber.Ctx, result interface{}) error

성공 메시지 및 데이터 반환

func Purify

func Purify(input string) string

순수한 문자(영어는 소문자), 숫자만 남기고 특수기호, 공백 등은 제거

func ResizeImage

func ResizeImage(inputPath string, outputPath string, width uint) error

이미지를 주어진 크기로 줄여서 .webp 형식으로 저장하기

func ResponseAuthFail added in v1.0.2

func ResponseAuthFail(c fiber.Ctx, userUid int) error

인증 실패 코드에 맞춰서 클라이언트에 리턴

func Sanitize

func Sanitize(input string) string

입력 문자열 중 HTML 태그들은 허용된 것만 남겨두기

func SaveAttachmentFile

func SaveAttachmentFile(file *multipart.FileHeader) (string, error)

업로드 된 파일을 attachments 폴더에 저장하고 경로 반환

func SaveCookie

func SaveCookie(c fiber.Ctx, name string, value string, days int)

리프레시 토큰을 쿠키에 저장

func SaveImage

func SaveImage(inputBuffer []byte, outputPath string, width uint) error

바이트 버퍼 이미지를 지정된 크기로 줄여서 .webp 형식으로 저장

func SaveInsertImage

func SaveInsertImage(inputPath string) (string, error)

본문 삽입용 이미지 저장하고 경로 반환

func SaveProfileImage

func SaveProfileImage(inputPath string) (string, error)

프로필 이미지 저장하고 경로 반환

func SaveThumbnailImage

func SaveThumbnailImage(inputPath string) (models.BoardThumbnail, error)

썸네일 이미지 저장하고 경로 반환

func SaveUploadedFile

func SaveUploadedFile(file multipart.File, fileName string) (string, error)

업로드 된 파일을 임시 폴더에 저장하고 경로 반환

func SendMail

func SendMail(to string, subject string, body string) bool

func Unescape

func Unescape(escaped string) string

HTML 문자열 이스케이프 해제

func ValidateJWT

func ValidateJWT(tokenStr string) (*jwt.Token, error)

JWT 토큰 검증

Types

This section is empty.

Jump to

Keyboard shortcuts

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