Documentation ¶
Index ¶
- func GetConfigurationFromSources(sources []source.Source) (config.Config, error)
- func LogErrorNonNil(logger Logger, err error, wrap ...string) error
- func LogFatalNonNil(logger Logger, err error, wrap ...string)
- func Write200Json(w http.ResponseWriter, content string)
- func Write201Json(w http.ResponseWriter, content string)
- func Write204(w http.ResponseWriter, content string)
- func Write401Json(w http.ResponseWriter)
- func Write404Json(w http.ResponseWriter)
- func Write500Json(w http.ResponseWriter, message string)
- func WriteJson(w http.ResponseWriter, content string, code int)
- func WriteStructToJson(w http.ResponseWriter, content interface{}, code int)
- type Application
- type Configuration
- type DefaultLogger
- type EmailAddress
- type Extension
- type Group
- type GroupMembership
- type GroupPrivilege
- type HeaderConfiguration
- type Logger
- type MailSendResponse
- type MailSender
- type NoOpExtension
- type SearchParameters
- type SearchResults
- type SilentLogger
- type SortByFieldParameters
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetConfigurationFromSources ¶
GetConfigurationFromSources will handle loading a configuration from a provided list of sources
func LogErrorNonNil ¶ added in v0.14.0
LogErrorNonNil is a utility function that allows for a conditional check against an error in such a way that it logs the error if it is non-nil. It also allows for an optional "wrap" string to provide extra context to the message
func LogFatalNonNil ¶ added in v0.14.0
LogFatalNonNil is a utility function that handles a conditional check against an error in such a way that it treats non-nil errors as fatal. Specifically, it exits with a non-zero code
func Write200Json ¶ added in v0.3.4
func Write200Json(w http.ResponseWriter, content string)
Write200Json is some syntactic sugar to allow for a quick way to write JSON responses with an OK code
func Write201Json ¶ added in v0.21.0
func Write201Json(w http.ResponseWriter, content string)
Write201Json is some syntactic sugar to allow for a quick way to write JSON responses with an OK code
func Write204 ¶ added in v0.21.0
func Write204(w http.ResponseWriter, content string)
Write204 is some syntactic sugar to allow for a quick way to write JSON responses with a no-content code
func Write404Json ¶
func Write404Json(w http.ResponseWriter)
Write404Json is some syntactic sugar to allow for a quick way to write JSON responses with a StatusNotFound code
func Write500Json ¶
func Write500Json(w http.ResponseWriter, message string)
Write500Json is some syntactic sugar to allow for a quick way to write JSON responses with an InternalServererror code
func WriteJson ¶ added in v0.14.0
func WriteJson(w http.ResponseWriter, content string, code int)
WriteJson is some syntactic sugar to allow for a quick way to write JSON responses with a status code
func WriteStructToJson ¶ added in v0.23.1
func WriteStructToJson(w http.ResponseWriter, content interface{}, code int)
WriteJson is some syntactic sugar to allow for a quick way to write JSON responses from structs with a status code
Types ¶
type Application ¶
type Application struct { Config *Configuration Logger Logger Router *mux.Router // contains filtered or unexported fields }
Application stores the state of the running application
func (*Application) Init ¶
func (ac *Application) Init(config *Configuration, logger Logger, extensions []Extension) error
func (*Application) Run ¶
func (ac *Application) Run() error
Run will put the app into its running state
type Configuration ¶
type Configuration struct { Headers HeaderConfiguration Port int Raw config.Config ApiPrefix string StaticDirectory string }
Configuration is the composite of other configs, including values directly from external sources (Raw)
func LoadConfiguration ¶ added in v0.2.0
func LoadConfiguration(sources ...source.Source) (*Configuration, error)
LoadConfiguration will handle loading the configuration from multiple sources, allowing for this module's default source set to be used if none are provided to this function
"merging priority is in reverse order" if nil or empty, file and environment sources used (file takes precedence)
type DefaultLogger ¶
type DefaultLogger struct{}
DefaultLogger logs using Go's standard "log" package, always via Println
func (DefaultLogger) Debug ¶
func (logger DefaultLogger) Debug(message ...string)
func (DefaultLogger) Error ¶
func (logger DefaultLogger) Error(message ...string)
func (DefaultLogger) Info ¶
func (logger DefaultLogger) Info(message ...string)
func (DefaultLogger) Trace ¶ added in v0.14.0
func (logger DefaultLogger) Trace(message ...string)
func (DefaultLogger) Warn ¶
func (logger DefaultLogger) Warn(message ...string)
type EmailAddress ¶ added in v0.8.0
type Extension ¶
type Extension interface { // GetName returns a static name for the extension, primarily for logging purposes GetName() string // Init should handle the initialization of the extension with the knowledge that the Router and other Extensions // are not likely to be initialized yet Init(app *Application) error // PostInit should handle all initialization that could not be handled in Init. Specifically, anything requiring // the Router and other Extensions to be initialized PostInit(app *Application) error // Destroy handles application shutdown, with the most recently-initialized extensions destroyed first Destroy(app *Application) error }
type Group ¶ added in v0.10.0
type Group struct { ID string `json:"id" bson:"_id" gorm:"primary_key"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"` Name string `json:"name"` Type string `json:"type"` Context *string `json:"data,omitempty"` Privileges []GroupPrivilege `json:"privileges"` }
type GroupMembership ¶ added in v0.10.0
type GroupMembership struct { ID string `json:"id" bson:"_id" gorm:"primary_key"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"` GroupID string `json:"groupId"` MemberID string `json:"memberId"` Role string `json:"role"` }
type GroupPrivilege ¶ added in v0.10.0
type GroupPrivilege struct { ID string `json:"id" bson:"_id" gorm:"primary_key"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"` GroupID string `json:"groupID" gorm:"foreignkey:GroupID"` // "performing group id" e.g. "administrators" ID ResourceID string `json:"resourceID"` // e.g. "customers" ID Action string `json:"action"` // e.g. read/write/admin/etc }
type HeaderConfiguration ¶
type HeaderConfiguration struct { AccessControlAllowHeaders string AccessControlAllowMethods string AccessControlAllowOrigin string }
HeaderConfiguration controls settings for request/response headers
type Logger ¶
type Logger interface { Trace(message ...string) Debug(message ...string) Error(message ...string) Info(message ...string) Warn(message ...string) }
Logger is a generic interface to reflect logging output at various levels
type MailSendResponse ¶ added in v0.8.0
type MailSender ¶ added in v0.8.0
type MailSender interface {
SendMail(from *EmailAddress, subject string, to []*EmailAddress, plainTextContent string, htmlContent string) (*MailSendResponse, error)
}
type NoOpExtension ¶
type NoOpExtension struct {
Logger Logger
}
NoOpExtension implements nibbler.Extension, but all methods do nothing This is provided as a base class that can be used to more tersely define extensions
func (*NoOpExtension) Destroy ¶
func (s *NoOpExtension) Destroy(app *Application) error
func (*NoOpExtension) GetName ¶ added in v0.14.0
func (s *NoOpExtension) GetName() string
func (*NoOpExtension) Init ¶
func (s *NoOpExtension) Init(app *Application) error
func (*NoOpExtension) PostInit ¶ added in v0.14.0
func (s *NoOpExtension) PostInit(app *Application) error
type SearchParameters ¶ added in v0.21.0
type SearchParameters struct { Query interface{} `json:"query,omitempty"` Offset *int `json:"offset,omitempty"` Size *int `json:"size,omitempty"` IncludeTotal bool `json:"includeTotal"` SortBy []SortByFieldParameters `json:"sortBy"` }
type SearchResults ¶ added in v0.21.0
type SilentLogger ¶
type SilentLogger struct{}
SilentLogger simply doesn't do anything when logs are to be written
func (SilentLogger) Debug ¶
func (logger SilentLogger) Debug(message ...string)
func (SilentLogger) Error ¶
func (logger SilentLogger) Error(message ...string)
func (SilentLogger) Info ¶
func (logger SilentLogger) Info(message ...string)
func (SilentLogger) Trace ¶ added in v0.14.0
func (logger SilentLogger) Trace(message ...string)
func (SilentLogger) Warn ¶
func (logger SilentLogger) Warn(message ...string)
type SortByFieldParameters ¶ added in v0.23.1
type User ¶ added in v0.10.0
type User struct { ID string `json:"id" bson:"_id" gorm:"primary_key"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt *time.Time `json:"deletedAt,omitempty" sql:"index"` Email *string `json:"email,omitempty" gorm:"unique"` Username *string `json:"username,omitempty" gorm:"unique"` FirstName *string `json:"firstName,omitempty"` MiddleName *string `json:"middleName,omitempty"` LastName *string `json:"lastName,omitempty"` MaidenName *string `json:"maidenName,omitempty"` Title *string `json:"title,omitempty"` Password *string `json:"password,omitempty"` PortraitUri *string `json:"portraitUri,omitempty"` AvatarUri *string `json:"avatarUri,omitempty"` StatusText *string `json:"statusText,omitempty"` IsActive *bool `json:"isActive,omitempty"` IsEmailValidated *bool `json:"isEmailValidated,omitempty"` DeactivatedAt *time.Time `json:"deactivatedAt,omitempty"` LastLogin *time.Time `json:"lastLogin,omitempty"` FailedLoginCount *int8 `json:"failedLoginCount,omitempty"` Gender *string `json:"gender,omitempty" gorm:"size:1"` PhoneHome *string `json:"phoneHome,omitempty" gorm:"size:24"` PhoneWork *string `json:"phoneWork,omitempty" gorm:"size:24"` PhoneMobile *string `json:"phoneMobile,omitempty" gorm:"size:24"` PhoneOther *string `json:"phoneOther,omitempty" gorm:"size:24"` Fax *string `json:"fax,omitempty" gorm:"size:24"` Uri *string `json:"uri,omitempty"` Birthday *string `json:"birthday,omitempty"` Bio *string `json:"bio,omitempty"` AddressLine1 *string `json:"addressLine1,omitempty"` AddressLine2 *string `json:"addressLine2,omitempty"` AddressLine3 *string `json:"addressLine3,omitempty"` AddressCity *string `json:"addressCity,omitempty"` AddressStateOrProvince *string `json:"addressStateOrProvince,omitempty"` AddressPostalCode *string `gorm:"size:16" json:"postalCode,omitempty"` CountryCode *string `gorm:"size:3" json:"countryCode,omitempty"` CompanyID *string `json:"companyId,omitempty"` EmployeeID *string `json:"employeeId,omitempty"` SupervisorID *string `json:"supervisorId,omitempty"` CreatedByUserID *string `json:"createdByUserId,omitempty"` ReferenceID *string `json:"referenceId,omitempty"` PasswordResetToken *string `json:"passwordResetToken,omitempty"` PasswordResetExpiration *time.Time `json:"passwordResetExpiration,omitempty"` EmailValidationToken *string `json:"emailValidationToken,omitempty"` EmailValidationExpiration *time.Time `json:"emailValidationExpiration,omitempty"` EmploymentStartDate *time.Time `json:"employmentStartDate,omitempty"` EmploymentEndDate *time.Time `json:"employmentEndDate,omitempty"` ContractStartDate *time.Time `json:"contractStartDate,omitempty"` ContractEndDate *time.Time `json:"contractEndDate,omitempty"` PrimaryLocation *string `json:"primaryLocation,omitempty"` // e.g. lat/long, grid codes, etc CurrentGroupID *string `json:"currentGroupId,omitempty"` Context *string `json:"context,omitempty"` // to store extra data we don't have modeled ProtectedContext *string `json:"protectedContext,omitempty"` // to store extra data not modeled that users shouldn't see }