api

package module
v0.0.0-...-95ef731 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorNotFound     = errors.New("NotFound")
	ErrorConflict     = errors.New("Conflict")
	ErrorPassword     = errors.New("Password")
	ErrorUnauthorized = errors.New("Unauthorized")
	ErrorForbidden    = errors.New("Forbidden")
)

Functions

func FormatRequestPrint

func FormatRequestPrint(r *http.Request) string

func JsonValid

func JsonValid(c echo.Context, i interface{}) (err error)

func RespConflict

func RespConflict(k string, i interface{}) interface{}

func RespCreated

func RespCreated() interface{}

func RespHandlingError

func RespHandlingError(c echo.Context, api_err ApiError, i interface{}) (err error)

func RespInternelServerError

func RespInternelServerError() interface{}

func RespMessage

func RespMessage(m string, k *string, i interface{}) interface{}

func RespNoContent

func RespNoContent(k string, i interface{}) interface{}

func SessionDelete

func SessionDelete(c echo.Context)

func SessionSet

func SessionSet(c echo.Context, user *User)

Types

type Access

type Access struct {
	As []string `bson:"as" json:"as"`
	On string   `bson:"on" json:"on"`
}

type ApiError

type ApiError struct {
	Error     error
	Message   ResponseMessage
	Model     string
	Line      int
	FileName  string
	UserEmail string
	UserUuid  string
}

func GetError

func GetError(err error, message ResponseMessage) *ApiError

func (*ApiError) LogError

func (e *ApiError) LogError(c echo.Context, i interface{})

func (*ApiError) PrintErrorNoSession

func (e *ApiError) PrintErrorNoSession(c echo.Context, i interface{})

type Avatar

type Avatar struct {
	Url     string `json:"url"`
	Type    string `json:"type"`
	Updated int64  `json:"updated" validate:"required"`
	Created int64  `json:"created" validate:"required"`
}

type Confirmed

type Confirmed struct {
	Status   bool  `json:"status" bson:"status"`
	Modified int64 `json:"modified" bson:"modified,omitempty"`
}

type JsonError

type JsonError struct {
	Key   string
	Error string
}

func JsonErrorResponse

func JsonErrorResponse(e error) (j_list []JsonError)

type Modified

type Modified struct {
	Updated int64 `json:"updated" bson:"updated,omitempty"`
	Created int64 `json:"created" bson:"created,omitempty"`
}

type PasswordInfo

type PasswordInfo struct {
	Password []byte   `bson:"password" json:"-"`
	Hasher   string   `bson:"hasher" json:"-"`
	Modified Modified `bson:"modified" json:"-"`
}

type Profile

type Profile struct {
	ID          string   `bson:"_id" json:"id" validate:"required"`
	UserID      string   `bson:"user_id" json:"user_id" validate:"required"`
	Avatar      Avatar   `json:"avatar"`
	FirstName   string   `json:"first_name" validate:"required"`
	LastName    string   `json:"last_name" validate:"required"`
	FullName    string   `json:"full_name" validate:"required"`
	DisplayName string   `json:"display_name" validate:"required"`
	Gender      string   `json:"gender"`
	Country     string   `bson:"country" json:"country"`
	Modified    Modified `json:"modified" bson:"modified" validation:"required"`
}

type ResponseError

type ResponseError struct {
	Message string
	Data    string
	Key     string
}

type ResponseMessage

type ResponseMessage struct {
	Message string                 `json:"message"`
	Data    map[string]interface{} `json:"data,omitempty"`
}

type User

type User struct {
	ID            string       `json:"uuid" bson:"_id,omitempty" validation:"required,uuid"`
	Email         string       `json:"email" bson:"email" validation:"required,email"`
	Confirmed     Confirmed    `json:"confirmed" bson:"confirmed" validation:"required"`
	PrivacyPolicy Confirmed    `json:"privacy_policy" bson:"privacy_policy" validation:"required"`
	Modified      Modified     `json:"modified" bson:"modified" validation:"required"`
	PasswordInfo  PasswordInfo `json:"-" bson:"password"`
	Profile       Profile      `json:"profile" bson:"-"`
}

func SessionUserGet

func SessionUserGet(c echo.Context) (u *User, contains bool)

Jump to

Keyboard shortcuts

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