session

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: MIT Imports: 4 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DateTimeFMT = "2006-01-02T15:04:05.000Z"
)

Variables

View Source
var (
	EmailEmptyErr        = errors.New("error creating session email required but was empty")
	StartEmptyErr        = errors.New("error unmarshalling session start field required but was missing/empty")
	LastAccessedEmptyErr = errors.New("error unmarshalling session last accessed field required but was missing/empty")
)

Functions

func FormatTime added in v1.1.0

func FormatTime(t time.Time) (time.Time, error)

Types

type NewSessionDetails

type NewSessionDetails struct {
	Email string `json:"email"`
}

NewSessionDetails is the create HTTP request body required to creating new session

type Session

type Session struct {
	ID           string    `json:"id"`
	Email        string    `json:"email"`
	Start        time.Time `json:"start"`
	LastAccessed time.Time `json:"last_accessed"`
}

Session defines the structure required for a session

func New added in v1.1.0

func New(email string) (*Session, error)

New construct a new fully populated session object for the provided email. Returns session.EmailEmptyErr if the email is empty/blank, returns an error if a new session ID could not be generated.

func (*Session) MarshalJSON

func (s *Session) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshaller for Session objects. Handles marshalling time.Time fields into the expected date time format

func (*Session) UnmarshalJSON added in v1.1.0

func (s *Session) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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