Documentation
¶
Overview ¶
Package server provides rest-like api and serves static assets as well
Index ¶
- func GetHashedIP(r *http.Request) string
- func HashedIP(secret string) func(http.Handler) http.Handler
- func Logger(l log.L, secret string) func(http.Handler) http.Handler
- func StripSlashes(next http.Handler) http.Handler
- func Timeout(timeout time.Duration) func(http.Handler) http.Handler
- type Config
- type EmailSender
- type Messager
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHashedIP ¶ added in v1.9.2
GetHashedIP retrieves hashed IP from context
func HashedIP ¶ added in v1.9.2
HashedIP middleware adds anonymized IP to request context for audit logging
func StripSlashes ¶ added in v1.6.0
StripSlashes removes trailing slashes from URLs
Types ¶
type Config ¶ added in v1.3.0
type Config struct {
Domain []string // allowed domains list
WebRoot string
Protocol string
Branding string
Listen string // server listen address (ip:port or :port), defaults to :8080
SignKey string // sign key (will be hashed before use for IP anonymization)
// validation parameters
PinSize int
MaxPinAttempts int
MaxExpire time.Duration
// file upload settings
EnableFiles bool
MaxFileSize int64 // bytes, 0 means use default (1MB)
// authentication (optional)
AuthHash string // bcrypt hash of password, empty disables auth
SessionTTL time.Duration // session lifetime, defaults to 168h (7 days)
// email sharing (optional)
EmailEnabled bool
}
Config is a configuration for the server
type EmailSender ¶ added in v1.9.0
type EmailSender interface {
Send(ctx context.Context, req email.Request) error
GetDefaultFromName() string
}
EmailSender defines the interface for sending emails (consumer-side interface)
type Messager ¶
type Messager interface {
MakeMessage(duration time.Duration, msg, pin string) (result *store.Message, err error)
MakeFileMessage(req messager.FileRequest) (result *store.Message, err error)
LoadMessage(key, pin string) (msg *store.Message, err error)
IsFile(key string) bool // checks if message is a file without decrypting
}
Messager interface making and loading messages
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a rest with store
func (Server) WithEmail ¶ added in v1.9.0
func (s Server) WithEmail(sender EmailSender) Server
WithEmail sets the email sender for the server
Directories
¶
| Path | Synopsis |
|---|---|
|
Package assets provides embedded static files and templates
|
Package assets provides embedded static files and templates |
|
Package validator provides functionality for validating and sanitizing data.
|
Package validator provides functionality for validating and sanitizing data. |
Click to show internal directories.
Click to hide internal directories.