herald

package
v0.0.0-...-62abba7 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2015 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_CHANNEL = "Unsorted"
View Source
const VERSION = "0.1"

Variables

This section is empty.

Functions

func AuthPayloadFromHeader

func AuthPayloadFromHeader(req *http.Request) (string, error)

func AuthPayloadFromQuery

func AuthPayloadFromQuery(req *http.Request) (string, error)

func ErrorHandler

func ErrorHandler() gin.HandlerFunc

Simple middleware to catch any errors and write them to the response body.

func MakeAuthToken

func MakeAuthToken(payload string, user *User) string

func RequestLogger

func RequestLogger() gin.HandlerFunc

func VersionBanner

func VersionBanner(color bool, extra string) string

Types

type Channel

type Channel struct {
	ID    int64  `json:"-"`
	Title string `sql:"type:varchar(50);unique"`
}

type Herald

type Herald struct {
	Addr         string
	DatabaseAddr string
	Debug        bool

	DB *HeraldDatabase
	// contains filtered or unexported fields
}

func (*Herald) HMACAuth

func (h *Herald) HMACAuth() gin.HandlerFunc

func (*Herald) Init

func (h *Herald) Init()

func (*Herald) Run

func (h *Herald) Run(addr string) error

type HeraldAPI

type HeraldAPI struct {
	Addr   string
	APIID  string
	APIKey string
}

func NewAPI

func NewAPI(addr, apiuser string) (*HeraldAPI, error)

func (*HeraldAPI) DelMsg

func (h *HeraldAPI) DelMsg(id int64) error

func (*HeraldAPI) GetMsg

func (h *HeraldAPI) GetMsg(id int64) (Message, error)

func (*HeraldAPI) ListenForNewMsgs

func (h *HeraldAPI) ListenForNewMsgs(msgcallback func(Message)) error

func (*HeraldAPI) NewMsg

func (h *HeraldAPI) NewMsg(msg, channel string) (Message, error)

func (*HeraldAPI) Search

func (h *HeraldAPI) Search(pattern, channel string, maxitems, page int) (MessageList, error)

func (*HeraldAPI) Status

func (h *HeraldAPI) Status() (HeraldStatus, error)

type HeraldDatabase

type HeraldDatabase struct {
	DB gorm.DB
}

func (*HeraldDatabase) CreateNewMessage

func (db *HeraldDatabase) CreateNewMessage(u *User, msg, channel string) (*Message, error)

func (*HeraldDatabase) CreateNewUser

func (db *HeraldDatabase) CreateNewUser(name string) (*User, error)

Create a new user with a randomized PublicID and PrivateKey hashes. Setting a name is optional and doesn't need to be unique.

func (*HeraldDatabase) DeleteMessage

func (db *HeraldDatabase) DeleteMessage(u *User, id int64) (bool, error)

func (*HeraldDatabase) DeleteUser

func (db *HeraldDatabase) DeleteUser(id int64)

func (*HeraldDatabase) GetAllUsers

func (db *HeraldDatabase) GetAllUsers() []*User

func (*HeraldDatabase) GetMessage

func (db *HeraldDatabase) GetMessage(id int64) (*Message, error)

func (*HeraldDatabase) GetMessages

func (db *HeraldDatabase) GetMessages(items, page int64, search, channel string) []*Message

func (*HeraldDatabase) GetStats

func (db *HeraldDatabase) GetStats() (int64, int64, int64)

func (*HeraldDatabase) GetUser

func (db *HeraldDatabase) GetUser(publicid string) (*User, error)

func (*HeraldDatabase) InitDB

func (db *HeraldDatabase) InitDB(path string)

func (*HeraldDatabase) InitSchema

func (db *HeraldDatabase) InitSchema()

type HeraldStatus

type HeraldStatus struct {
	Status   string
	Version  string
	Debug    bool
	Address  string
	Database string
	Messages int64
	Channels int64
	Users    int64
}

type Message

type Message struct {
	ID        int64
	Created   int64
	Message   string `sql:"type:text;not null"`
	ChannelID int64  `json:"-"`
	Channel   Channel
	UserId    int64 `json:"-"`
	User      User
}

type MessageList

type MessageList struct {
	Count    int64
	Messages []Message
}

type User

type User struct {
	ID         int64  `json:"-"`
	Name       string `sql:"type" varchar(64)"`
	PublicID   string `sql:"type: varchar(64);unique"`
	PrivateKey string `json:"-"`
}

Jump to

Keyboard shortcuts

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