server

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: MIT Imports: 22 Imported by: 5

Documentation

Overview

Package server provides network listeners, e.g. an HTTP (web/REST/JSON) server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateJWT added in v0.1.15

func CreateJWT(username string, ttl int, secret string) (string, error)

func GenerateId added in v0.1.19

func GenerateId(size int) string

Generate a (hopefully) unique cryptographically secure identifier. The size parameter is specified in 4-byte (= 32-bit) units, so `generateId(2) returns a 64-bit Id. The returned Id is a URL-safe base64-encoded string.

func GetSid added in v0.1.8

func GetSid(req *http.Request) string

func GetSidHdr added in v0.1.19

func GetSidHdr(hdr http.Header) (sid string)

func ParseJWT added in v0.1.15

func ParseJWT(tk, secret string) (jwt.Claims, error)

func Route

func Route(ctx *b.Context, spec m.Map, hdlr RqHandler,
	req *http.Request, rsp http.ResponseWriter)

func SetSid added in v0.1.9

func SetSid(rsp http.ResponseWriter, sid string)

func SetSidHdr added in v0.1.19

func SetSidHdr(hdr http.Header, sid string)

Types

type RqActionHandler

type RqActionHandler = func(*b.Context, m.Map, *b.Message,
	*http.Request, http.ResponseWriter, *Session)

func GetActionHandler

func GetActionHandler(ctx *b.Context, spec m.Map, msg *b.Message) RqActionHandler

type RqHandler added in v0.1.13

type RqHandler = func(*b.Context, m.Map,
	*http.Request, http.ResponseWriter)

func GetRequestHandler added in v0.1.13

func GetRequestHandler(ctx *b.Context, spec m.Map) (string, RqHandler)

type ServerState added in v0.1.8

type ServerState struct {
	Server   *http.Server
	Sessions *Sessions
}

func (*ServerState) GetSession added in v0.1.19

func (st *ServerState) GetSession(sid string) b.Session

type Session added in v0.1.8

type Session struct {
	SessionId string
	Timestamp int64 // check lifetime/clean-up - when?
	Data      m.Map // metadata, e.g. about user, ...
	// contains filtered or unexported fields
}

func (*Session) GetMailbox added in v0.1.19

func (s *Session) GetMailbox() b.Mailbox

legacy/deprecated, use `GetRMailbox()` instead

func (*Session) GetRMailbox added in v0.1.19

func (s *Session) GetRMailbox(iid string) *mbInfo

Return a mailbox for this request. Make sure to release unused mailboxes when finished using: `defer s.ReleaseMailbox(mb, <del>)`

func (*Session) ReleaseMailbox added in v0.1.19

func (s *Session) ReleaseMailbox(mb *mbInfo)

func (*Session) Send added in v0.1.19

func (s *Session) Send(ctx *b.Context, msg *b.Message)

type Sessions added in v0.1.8

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

func (*Sessions) Get added in v0.1.8

func (s *Sessions) Get(ctx *b.Context, sid string) *Session

Jump to

Keyboard shortcuts

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