utils

package
v0.0.0-...-779ed6b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType     = "Content-Type"
	ApplicationJSON = "application/json;charset=utf-8"
	Cors            = "Access-Control-Allow-Origin"
	ArrowHeader     = "Access-Control-Allow-Headers"
	Credential      = "Access-Control-Allow-Credentials"
	ArrowMethods    = "Access-Control-Allow-Methods"
	Methods         = "PUT,POST,GET,DELETE,OPTIONS"
	True            = "true"
	CorsWildCard    = "*"
	Authorization   = "Authorization"
)

Application form type

View Source
const (
	Post    = "POST"
	Get     = "GET"
	Put     = "PUT"
	Delete  = "DELETE"
	Options = "OPTIONS"
)

HTTP request method

View Source
const (
	Trending           = "/"
	Timeline           = "/timeline"
	LoginPath          = "/login"
	SignUpPath         = "/signUp"
	LikePost           = "/likePost"
	DeleteLikedPost    = "/deleteLikedPost"
	ShowFavoritePosts  = "/favoritePostsList"
	FavoritePost       = "/favoritePost"
	DeleteFavoritePost = "/deleteFavorite"
	UserPostsList      = "/userPostsList"
	SinglePost         = "/post"
	NewPost            = "/newPost"
	EditPost           = "/editPost"
	DeletePost         = "/deletePost"
	ShowProfile        = "/showProfile"
	EditProfile        = "/editProfile"
	DeleteAccount      = "/deleteAccount"
	UploadingIcon      = "/uploadIcon"
	ChangeIcon         = "/changeIcon"
	UploadingImages    = "/uploadingImages"
	DeleteImages       = "/deleteImages"
)

Each path

View Source
const (
	SuccessCode                   = 0
	WrongUserNamePassword         = 1
	InvalidToken                  = 2
	InvalidSignUpUsername         = 3
	InvalidSignUpMailAddress      = 4
	InvalidSignUpPassword         = 5
	NotMatchPasswords             = 6
	FailedLoginCode               = 7
	FailedDeleteLike              = 8
	FailedFavoritePost            = 9
	FailedDeleteFavorite          = 10
	FailedDeletePost              = 11
	InvalidCreateTitle            = 12
	InvalidCreateContent          = 13
	InvalidEditTitle              = 14
	InvalidEditContent            = 15
	InvalidEditProfileUserName    = 16
	InvalidEditProfileBirthday    = 17
	InvalidEditProfileMailAddress = 18
	InvalidEditProfileComment     = 19
	FailedDeleteAccount           = 20
	FailedEditProfile             = 21
	FailedEditPost                = 22
	OverSizeIcon                  = 23
	NoIconSelected                = 24
	FailedRegisterIcon            = 25
	FailedDeleteIconFromS3        = 26
	FailedUpdateIcon              = 27
	FailedGenerateAWSSession      = 28
	FailedUploadImages            = 29
	GetEmptyIconURL               = 30
	FailedDeleteIconFromDB        = 31
	FailedGetProfile              = 32
	FailedCreateNewPost           = 33
	InvalidDeleteImageURL         = 34
	FailedDeleteImages            = 35
	FailedDeleteImageFromDB       = 36
	InvalidExtension              = 37
)

Error code

View Source
const LogFile = "./all-the-logs.log"

LogFile is the Log file path

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(userID int) string

CreateToken creates JWT.

func DBInit

func DBInit() (*sql.DB, error)

DBInit initialize MySQL connection.

func DeleteBucket

func DeleteBucket(s *session.Session, icon string) bool

DeleteBucket delete icon from aws bucket.

func IsBirthday

func IsBirthday(birthday string) bool

IsBirthday checks if a value is valid birthday.

func IsComment

func IsComment(comment string) bool

IsComment checks if a value si valid comment. It checks - a value is not empty. - a value's length is 1 to 140. It returns a result in boolean.

func IsContent

func IsContent(content string) bool

IsContent checks if a value is valied content. It checks - a value is not empty. - a value's length is 1 to 500. It returns a result in boolean.

func IsEmailAddress

func IsEmailAddress(emailAddress string) bool

IsEmailAddress checks if email address in paramter can be valid. It checks if mail address is matched to mail address pattern. It returns true or false.

func IsID

func IsID(ID int) bool

IsID checks if a value is valid. It checks - a value is larger than 0. It returns a result in boolean.

func IsImageURL

func IsImageURL(imageURL []string) bool

IsImageURL is a validation method that tests if string get from request is empty.

func IsName

func IsName(name string) bool

IsName checks if name in parameter can be usable. It checks if name length is not 0 and 1 to 20. This returns true or false.

func IsPassword

func IsPassword(password string) bool

IsPassword checks if password in parameter is valid. It checks ・The length is least 8 character and less than 20 character. ・At least one number is contained. ・At least one special caracter. It returns true or false.

func IsTitle

func IsTitle(title string) bool

IsTitle checks if a value is valied title. It checks - a value is not empty. - a value's length is 1 to 50. It returns a result in boolean.

func UploadingToS3

func UploadingToS3(s *session.Session, file multipart.File, fileHeader *multipart.FileHeader) (string, error)

UploadingToS3 saves a file to aws bucket

func VerifyToken

func VerifyToken(reqHead string) int

VerifyToken checks if token is valid.

Types

This section is empty.

Jump to

Keyboard shortcuts

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