seed: github.com/qlova/seed/user Index | Files | Directories

package user

import "github.com/qlova/seed/user"

Package user allows communication with users from Go code.

Index

Package Files

args.go attachment.go connection.go errors.go map.go user.go

func Save Uses

func Save(u Ctx, name string) error

Save saves the user-context under the given key which can be retrieved at a later time with Load.

type Arg Uses

type Arg struct {
    // contains filtered or unexported fields
}

Arg is a user provided argument.

func (Arg) Decode Uses

func (arg Arg) Decode(i interface{}) error

Decode decodes the value into the given argument.

func (Arg) InterfaceMap Uses

func (arg Arg) InterfaceMap() (returns map[string]interface{}, err error)

InterfaceMap returns the argument as a map of interface values.

func (Arg) String Uses

func (arg Arg) String() string

String returns the argument as a string.

func (Arg) Strings Uses

func (arg Arg) Strings() (returns []string, err error)

Strings returns the argument as a slice of strings.

type Attachment Uses

type Attachment struct {
    // contains filtered or unexported fields
}

Attachment is file that a user has attached to a request.

func (Attachment) Name Uses

func (a Attachment) Name() string

Name returns the name of the attachment.

func (Attachment) Open Uses

func (a Attachment) Open() io.ReadCloser

Open returns a reader to the attachment.

func (Attachment) Size Uses

func (a Attachment) Size() int64

Size returns the size of the attachment.

type Ctx Uses

type Ctx struct {
    // contains filtered or unexported fields
}

Ctx is a user-context, meaning a current connection to a user of you're application.

func CtxFromHandler Uses

func CtxFromHandler(w http.ResponseWriter, r *http.Request) Ctx

CtxFromHandler returns a user ctx from the request and responsewriter inside an http Handler.

func CtxFromSocket Uses

func CtxFromSocket(r *http.Request, w http.ResponseWriter) (Ctx, error)

CtxFromSocket creates a new user from an incomming websocket request.

func Load Uses

func Load(name string) (Ctx, error)

Load loads a user under the given name.

func (Ctx) AreConnected Uses

func (u Ctx) AreConnected() bool

AreConnected returns true if the user is connected.

func (Ctx) AreHacking Uses

func (u Ctx) AreHacking()

AreHacking sends an HTTP 400 status code to the user.

func (Ctx) AreLost Uses

func (u Ctx) AreLost()

AreLost sends an HTTP 404 status code to the user.

func (Ctx) AreNotAdmin Uses

func (u Ctx) AreNotAdmin()

AreNotAdmin sends an HTTP 403 status code to the user.

func (Ctx) Arg Uses

func (u Ctx) Arg(name string) Arg

Arg returns the argument with the given name.

func (Ctx) Attachment Uses

func (u Ctx) Attachment(index ...int) (attachment Attachment)

Attachment retrieve either the first attachment or if index is provided, the attachment at the specified index. This can be used to recieve files from the user.

func (Ctx) Execute Uses

func (u Ctx) Execute(script string)

Execute sends and evaluates the provided javascript.

func (Ctx) NeedToLogin Uses

func (u Ctx) NeedToLogin()

NeedToLogin sends an HTTP 401 status code to the user.

func (Ctx) NeedToPurchase Uses

func (u Ctx) NeedToPurchase()

NeedToPurchase sends an HTTP 402 status code to the user.

func (Ctx) Report Uses

func (u Ctx) Report(err error)

Report reports the provided error to the user, it should not be used for errors containing sensitive information.

func (Ctx) Request Uses

func (u Ctx) Request() *http.Request

Request returns the Request passed to the Ctx when it was created.

func (Ctx) ResponseWriter Uses

func (u Ctx) ResponseWriter() http.ResponseWriter

ResponseWriter returns the ResponseWriter passed to the Ctx when it was created.

func (*Ctx) Upgrade Uses

func (u *Ctx) Upgrade() error

Upgrade converts a incoming user from an HTTP request to a socket.

func (Ctx) Valid Uses

func (u Ctx) Valid() bool

Valid returns true if the context is valid.

type Handler Uses

type Handler func(Ctx)

Handler is a user handler.

Directories

PathSynopsis
password
session

Package user imports 11 packages (graph) and is imported by 12 packages. Updated 2020-03-21. Refresh now. Tools for package owners.