Documentation
¶
Index ¶
- Constants
- Variables
- func CreateConfig(conf *Config, hash string, key string) error
- func CreateOrUpdateAvatar(conf *Config, addr saltyim.Addr, contents []byte) error
- func CreateOrUpdateBlob(conf *Config, key string, data []byte, signer string) error
- func DeleteBlob(conf *Config, key string, signer string) error
- func FileExists(name string) bool
- func GenerateAvatar(conf *Config, domainNick string) (image.Image, error)
- func GenerateRandomToken() string
- func GetBlob(conf *Config, key string, signer string) (*saltyim.Blob, error)
- func InitJobs(conf *Config)
- func IsImage(data []byte) bool
- func NewSyncStoreJob(conf *Config, db Store) cron.Job
- func NewTestUser(addr, broker string, t *testing.T) *saltyim.Client
- func ProcessImage(r io.Reader, opts *ImageOptions) (image.Image, error)
- func SaveAvatar(fn string, r io.Reader, size int) error
- type API
- type Config
- type ImageOptions
- type JobFactory
- type JobSpec
- type Middleware
- type Option
- func WithAdminUser(adminUser string) Option
- func WithBaseURL(baseURL string) Option
- func WithData(data string) Option
- func WithDebug(debug bool) Option
- func WithPrimaryDomain(primaryDomain string) Option
- func WithStore(store string) Option
- func WithSupportEmail(supportEmail string) Option
- func WithTLS(tls bool) Option
- func WithTLSCert(tlsCert string) Option
- func WithTLSKey(tlsKey string) Option
- type Router
- func (r *Router) DELETE(path string, handle httprouter.Handle)
- func (r *Router) File(path, name string)
- func (r *Router) GET(path string, handle httprouter.Handle)
- func (r *Router) Group(path string, m ...Middleware) *Router
- func (r *Router) HEAD(path string, handle httprouter.Handle)
- func (r *Router) Handle(method, path string, handle httprouter.Handle)
- func (r *Router) Handler(method, path string, handler http.Handler)
- func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
- func (r *Router) OPTIONS(path string, handle httprouter.Handle)
- func (r *Router) PATCH(path string, handle httprouter.Handle)
- func (r *Router) POST(path string, handle httprouter.Handle)
- func (r *Router) PUT(path string, handle httprouter.Handle)
- func (r *Router) ServeFilesWithCacheControl(path string, root fs.FS)
- func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (r *Router) Static(path, root string)
- func (r *Router) Use(m ...Middleware) *Router
- type Server
- func (s *Server) AddCronJob(spec string, job cron.Job) error
- func (s *Server) AddRoute(method, path string, handler http.Handler)
- func (s *Server) AddShutdownHook(f func())
- func (s *Server) AvatarHandler() httprouter.Handle
- func (s *Server) ConfigHandler() httprouter.Handle
- func (s *Server) IndexHandler() httprouter.Handle
- func (s *Server) ListenAndServe() error
- func (s *Server) NotFoundHandler(w http.ResponseWriter, r *http.Request)
- func (s *Server) Run(ctx context.Context) (err error)
- func (s *Server) Shutdown(ctx context.Context) error
- type Store
- type StoreURI
- type SyncStoreJob
Constants ¶
const ( // InvalidConfigValue is the constant value for invalid config values // which must be changed for production configurations before successful // startup InvalidConfigValue = "INVALID CONFIG VALUE - PLEASE CHANGE THIS VALUE" // DefaultDebug is the default debug mode DefaultDebug = false // DefaultTLS is the default for whether to enable TLS DefaultTLS = false // DefaultTLSKey is the default path to a TLS private key (if blank uses Let's Encrypt) DefaultTLSKey = "" // DefaultTLSCert is the default path to a TLS certificate (if blank uses Let's Encrypt) DefaultTLSCert = "" // DefaultData is the default data directory for storage DefaultData = "./data" // DefaultStore is the default data store used for accounts, sessions, etc DefaultStore = "bitcask://data/saltyim.db" // DefaultBaseURL is the default Base URL for the server DefaultBaseURL = "https://salty." + DefaultPrimaryDomain // DefaultPrimaryDomain is the default primary domain delegated to this broker DefaultPrimaryDomain = "home.arpa" // DefaultAdminUser is the default publickye to grant admin privileges to DefaultAdminUser = "" // DefaultSupportEmail is the default email of the admin user used in support requests DefaultSupportEmail = "support@" + DefaultPrimaryDomain )
Variables ¶
var ( Jobs map[string]JobSpec StartupJobs map[string]JobSpec )
var ( ErrInvalidStore = errors.New("error: invalid store") ErrPollNotFound = errors.New("error: poll not found") )
var ( ErrAddressExists = errors.New("error: address already exists") ErrBlobNotFound = errors.New("error: blob not found") )
Functions ¶
func CreateOrUpdateAvatar ¶
func CreateOrUpdateBlob ¶
func FileExists ¶
FileExists returns true if the given file exists
func GenerateAvatar ¶
GenerateAvatar generates a unique avatar for a user based on an identicon
func GenerateRandomToken ¶
func GenerateRandomToken() string
GenerateRandomToken generates random tokens used primarily for recovery
func ProcessImage ¶
ProcessImage processes an image and resizes the image according to the image options provided and returns a new image for storage or to be served
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API ...
func (*API) RegisterEndpoint ¶
func (a *API) RegisterEndpoint() httprouter.Handle
RegisterEndpoint ...
type Config ¶
type Config struct { Debug bool TLS bool `json:"-"` TLSKey string `json:"-"` TLSCert string `json:"-"` Data string `json:"-"` Store string `json:"-"` BaseURL string BrokerURI string PrimaryDomain string AdminUser string `json:"-"` SupportEmail string `json:"-"` // contains filtered or unexported fields }
Config contains the server configuration parameters
type ImageOptions ¶
ImageOptions set options for handling image resizing
type JobSpec ¶
type JobSpec struct { Schedule string Factory JobFactory }
JobSpec ...
func NewJobSpec ¶
func NewJobSpec(schedule string, factory JobFactory) JobSpec
type Option ¶
Option is a function that takes a config struct and modifies it
func WithAdminUser ¶
WithAdminUser sets the Admin user used for granting special features to
func WithBaseURL ¶
WithBaseURL sets the Base URL used for constructing feed URLs
func WithPrimaryDomain ¶
WithPrimaryDomain sets the Primary Domain this broker is delegated for
func WithSupportEmail ¶
WithSupportEmail sets the Support email used to contact the operator of this broker
func WithTLSCert ¶
WithTLSCert sets the path to a TLS certificate
func WithTLSKey ¶
WithTLSKey sets the path to a TLS private key
type Router ¶
type Router struct { httprouter.Router // contains filtered or unexported fields }
Router ...
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handle httprouter.Handle)
DELETE is a shortcut for Router.Handle("DELETE", path, handle)
func (*Router) GET ¶
func (r *Router) GET(path string, handle httprouter.Handle)
GET is a shortcut for Router.Handle("GET", path, handle)
func (*Router) Group ¶
func (r *Router) Group(path string, m ...Middleware) *Router
Group returns new *Router with given path and middlewares. It should be used for handles which have same path prefix or common middlewares.
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, handle httprouter.Handle)
HEAD is a shortcut for Router.Handle("HEAD", path, handle)
func (*Router) Handle ¶
func (r *Router) Handle(method, path string, handle httprouter.Handle)
Handle registers a new request handle combined with middlewares.
func (*Router) HandlerFunc ¶
func (r *Router) HandlerFunc(method, path string, handler http.HandlerFunc)
HandlerFunc is an adapter for http.HandlerFunc.
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, handle httprouter.Handle)
OPTIONS is a shortcut for Router.Handle("OPTIONS", path, handle)
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handle httprouter.Handle)
PATCH is a shortcut for Router.Handle("PATCH", path, handle)
func (*Router) POST ¶
func (r *Router) POST(path string, handle httprouter.Handle)
POST is a shortcut for Router.Handle("POST", path, handle)
func (*Router) PUT ¶
func (r *Router) PUT(path string, handle httprouter.Handle)
PUT is a shortcut for Router.Handle("PUT", path, handle)
func (*Router) ServeFilesWithCacheControl ¶
ServeFilesWithCacheControl ...
func (*Router) Use ¶
func (r *Router) Use(m ...Middleware) *Router
Use appends new middleware to current Router.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server ...
func (*Server) AddCronJob ¶
AddCronJob ...
func (*Server) NotFoundHandler ¶
func (s *Server) NotFoundHandler(w http.ResponseWriter, r *http.Request)
type StoreURI ¶
func ParseStoreURI ¶
type SyncStoreJob ¶
type SyncStoreJob struct {
// contains filtered or unexported fields
}
func (*SyncStoreJob) Run ¶
func (job *SyncStoreJob) Run()
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
Package app implements a terminal user interface (tui)
|
Package app implements a terminal user interface (tui) |
Package authreq signa and verifies HTTP requests using Ed25519 private/public keys
|
Package authreq signa and verifies HTTP requests using Ed25519 private/public keys |
Package main implements the PWA (progressive web app) using the go-app framework
|
Package main implements the PWA (progressive web app) using the go-app framework |