utils

package
v0.0.0-...-1b1fb7f Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnvOrDefaultString

func EnvOrDefaultString(envVar string, defaultValue string) string

EnvOrDefaultString ...

func ErrorHandler

func ErrorHandler(err *ErrorWithStatusCode, res http.ResponseWriter)

ErrorHandler handles https error responses

func GenerateToken

func GenerateToken(tp *TokenPayload) (string, error)

GenerateToken ...

func JSONResponseHandler

func JSONResponseHandler(res http.ResponseWriter, statusCode int, payload interface{})

JSONResponseHandler handles http response in json

Types

type ContextKey

type ContextKey string

ContextKey ...

type ErrorResponse

type ErrorResponse struct {
	Message string      `json:"message"`
	Errors  interface{} `json:"errors,omitempty"`
}

ErrorResponse ...

type ErrorWithStatusCode

type ErrorWithStatusCode struct {
	StatusCode   int
	ErrorMessage error
	Errors       interface{}
}

ErrorWithStatusCode : This is error model.

type JWTClaims

type JWTClaims struct {
	ID    string `json:"id" bson:"id"`
	Email string `json:"email" bson:"email"`
	jwt.StandardClaims
}

JWTClaims ...

func DecodeToken

func DecodeToken(token string) (*JWTClaims, error)

DecodeToken ...

type TokenPayload

type TokenPayload struct {
	ID    string `json:"id" bson:"id"`
	Email string `json:"email" bson:"email"`
}

TokenPayload ...

Jump to

Keyboard shortcuts

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