utils

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLog

func AddLog(l1 log.Logger, l2 ...log.Logger)

AddLog to add logger chain.

func CleanWikiaComment

func CleanWikiaComment(str string) string

CleanWikiaComment to remove wikia comment.

func CleanWikiaTag

func CleanWikiaTag(str, tag string, deleteContent bool) string

CleanWikiaTag to remove wikia tag.

func Error

func Error(str string, args ...interface{})

Error to print error.

func Fatal

func Fatal(str string, args ...interface{})

Fatal to log fatal.

func GetKey

func GetKey(params ...interface{}) string

GetKey to generate cache key.

func GetLogger

func GetLogger(i ...int) log.Logger

GetLogger to get logger.

func GetWikiaExternalLink(str string) string

GetWikiaExternalLink to get wikia external link.

func Info

func Info(str string, args ...interface{})

Info to log info.

func InitLog

func InitLog(t log.LogType, lvl log.LogLevel, json, color bool) (err error)

InitLog to init global logger.

func Log

func Log(field map[string]interface{})

Log to log with custom field.

func Marshal

func Marshal(strs []string) string

func NormalizeNewLine

func NormalizeNewLine(str string) string

NormalizeNewLine to normalize new line to <br>.

func NormalizeWikiaInternalLink(str string) string

NormalizeWikiaInternalLink to normalize wikia internal link. [[NIJISANJI (main branch)|NIJISANJI]] => [[NIJISANJI]]

func Recoverer

func Recoverer(next http.Handler) http.Handler

Recoverer is custom recoverer middleware. Will return 500.

func RemoveAllHTMLTag

func RemoveAllHTMLTag(str string) string

RemoveAllHTMLTag to remove all html tag.

func ResponseWithJSON

func ResponseWithJSON(w http.ResponseWriter, code int, data interface{}, err error, meta ...interface{})

ResponseWithJSON to write response with JSON format.

func ResponseWithPNG added in v0.2.0

func ResponseWithPNG(w http.ResponseWriter, code int, data []byte, err error)

ResponseWithPNG to write response with PNG.

func Validate

func Validate(data interface{}) error

Validate to validate struct using validate tag. Use pointer.

func WikiaExternalLinkToStr

func WikiaExternalLinkToStr(str string) string

WikiaExternalLinkToStr to convert wikia external link to string.

func WikiaInternalLinkToStr

func WikiaInternalLinkToStr(str string) string

WikiaInternalLinkToStr to convert wikia internal link to string.

Types

type Response

type Response struct {
	Status  int         `json:"status"`
	Message string      `json:"message"`
	Data    interface{} `json:"data" swaggertype:"object"`
	Meta    interface{} `json:"meta" swaggertype:"object"`
}

Response is standard api response model.

Jump to

Keyboard shortcuts

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