Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessState ¶
type AccessState string
AccessState is a string representation of the broadest, general access an entity such as an Account or a User has to a trails application.
const ( AccessGranted AccessState = "granted" AccessInvited AccessState = "invited" AccessRevoked AccessState = "revoked" AccessVerifyEmail AccessState = "verify-email" )
func (AccessState) String ¶
func (as AccessState) String() string
String stringifies the AccessState.
String implements fmt.Stringer.
type Account ¶
type Account struct { Model AccessState AccessState `json:"accessState"` AccountOwnerID uint `json:"accountOwnerId"` // Associations AccountOwner *User `json:"accountOwner,omitempty"` Users []User `json:"users,omitempty"` }
An Account is a way many Users access a trails application and can be related to one another.
An Account has many Users. An Account has one User designated as the owner of the Account.
type DeletedTime ¶
DeletedTime is a nullable timestamp marking a record as soft deleted.
func (DeletedTime) DeleteClauses ¶
func (DeletedTime) DeleteClauses(f *schema.Field) []clause.Interface
Implements GORM-specific interfaces for modifying queries when DeletedTime is valid cf.: - https://github.com/go-gorm/gorm/blob/8dde09e0becd383bc24c7bd7d17e5600644667a8/soft_delete.go
func (DeletedTime) IsDeleted ¶
func (dt DeletedTime) IsDeleted() bool
IsDeleted asserts whether the record is soft deleted.
func (DeletedTime) QueryClauses ¶
func (DeletedTime) QueryClauses(f *schema.Field) []clause.Interface
func (DeletedTime) UpdateClauses ¶
func (DeletedTime) UpdateClauses(f *schema.Field) []clause.Interface
type Model ¶
type Model struct { ID uint `json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt DeletedTime `json:"deletedAt"` }
A Model is the essential data points for primary ID-based models in a trails application, indicating when a record was created, last updated and soft deleted.
type User ¶
type User struct { Model AccessState AccessState `json:"accessState"` AccountID uint `json:"accountId"` Email string `json:"email"` ExternalID uuid.UUID `json:"externalId"` Password []byte `json:"-"` // Associations Account *Account `json:"account,omitempty"` }
A User is the core entity that interacts with a trails application.
An agent's HTTP requests are authenticated first by a specific request with email & password data matching credentials stored on a DB record for a User. Upon a match, a session is created and stored. Further requests are authenticated by referencing that session.
A User has one Account.
Directories ¶
Path | Synopsis |
---|---|
http
|
|
example/second-example
second-example shows off a simple trails app that utilizes completely custom application code and defaults a user provides additional configuration to.
|
second-example shows off a simple trails app that utilizes completely custom application code and defaults a user provides additional configuration to. |
example/start-here
start-here provides a toy example use of Trails' http stack, focusing on the basics of:
|
start-here provides a toy example use of Trails' http stack, focusing on the basics of: |
example/third-example
third-example provides a more "robust" use of authentication and unauthentication, highlighting trails' flexibility to work with an application's own implementation of important interfaces describing the currentUser concept at the heart of trails.
|
third-example provides a more "robust" use of authentication and unauthentication, highlighting trails' flexibility to work with an application's own implementation of important interfaces describing the currentUser concept at the heart of trails. |
keyring
Package keyring defines how keys in a *http.Request.Context should behave and a way for storing and retrieving those keys for wider use in the application.
|
Package keyring defines how keys in a *http.Request.Context should behave and a way for storing and retrieving those keys for wider use in the application. |
middleware
The middleware package defines what a middleware is in trails and a set of basic middlewares.
|
The middleware package defines what a middleware is in trails and a set of basic middlewares. |
resp
Package resp provides a high-level API for responding to HTTP requests.
|
Package resp provides a high-level API for responding to HTTP requests. |
router
Package router defines what an HTTP server is and a default implementation of it.
|
Package router defines what an HTTP server is and a default implementation of it. |
template/templatetest
Package templatetest exposes a mock fs.FS that implements basic file operations.
|
Package templatetest exposes a mock fs.FS that implements basic file operations. |
Package logger provides logging functionality to a trails app by defining the required behavior in Logger and providing an implementation of it with TrailsLogger.
|
Package logger provides logging functionality to a trails app by defining the required behavior in Logger and providing an implementation of it with TrailsLogger. |
Package postgres manages our database connection.
|
Package postgres manages our database connection. |
Package ranger initializes and manages a trails app with sane defaults and custom configuration.
|
Package ranger initializes and manages a trails app with sane defaults and custom configuration. |