Documentation ¶
Overview ¶
Package goan contains the actual API; the main.go file simply shells out the execution to LoadAPI()
Index ¶
- Variables
- func CORSMiddleware() gin.HandlerFunc
- func CheckAuthentication(config *Config) gin.HandlerFunc
- func DeleteAllTestingEntriesMongo(entryType string, config *Config) error
- func GetDistinctEntries(config *Config, authenticated bool) (int, gin.H)
- func GetDistinctEntriesMongo(config *Config) ([]string, error)
- func GetEntriesByType(entryType string, from time.Time, to time.Time, sort Sort, config *Config, ...) (int, gin.H)
- func SaveEntry(entryType string, reference string, notes string, config *Config, ...) (int, gin.H)
- func SaveEntryMongo(data *DataEntry, config *Config) error
- func SetupLogger()
- type Config
- type DataEntry
- type Sort
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func CORSMiddleware ¶
func CORSMiddleware() gin.HandlerFunc
func CheckAuthentication ¶
func CheckAuthentication(config *Config) gin.HandlerFunc
CheckAuthentication will check the user's authentication token in either the post body or the query string (in that priority order)
func DeleteAllTestingEntriesMongo ¶
DeleteAllTestingEntriesMongo removes all entries of a specific type. While it can be used for all removals, including non-testing, you probably don't really want to delete all of your entries
func GetDistinctEntries ¶
GetDistinctEntries gets the distinct entries
func GetDistinctEntriesMongo ¶
GetDistinctEntriesMongo gets the distinct entry types that have been input
func GetEntriesByType ¶
func GetEntriesByType(entryType string, from time.Time, to time.Time, sort Sort, config *Config, authenticated bool) (int, gin.H)
GetEntriesByType gets a list of all entries filtered by a specific type
func SaveEntry ¶
func SaveEntry(entryType string, reference string, notes string, config *Config, authenticated bool) (int, gin.H)
SaveEntry saves a new event entry to the database
func SaveEntryMongo ¶
SaveEntryMongo saves a DataEntry struct to Mongo
Types ¶
type Config ¶
type Config struct { AuthenticationToken string Port string DatabaseType string // currently only Mongo, with MySQL and others coming soon* DatabaseName string DatabaseHost string DatabaseUser string DatabasePassword string DatabasePort string DatabaseURL string //overrides other entries DatabaseMongo mgo.Session }
Config holds basic configuration options for the application, including database settings and authentication
func LoadConfig ¶
LoadConfig will load up a new configuration struct with sane defaults if none provided
type DataEntry ¶
type DataEntry struct { MongoID bson.ObjectId `bson:"_id"` SQLID int `bson:"_sqlid"` EntryType string `bson:"entryType" json:"entryType"` Reference string `bson:"reference" json:"reference"` EntryCreated time.Time `bson:"entryCreated" json:"entryCreated"` Notes string `bson:"notes" json:"notes"` }
DataEntry is the primary data structure for the events that are logged
The primary fields are: - EntryType: The type of event, such as "login" or "userSubscribed" - Reference: An optional field for referencing another record. For example, if the "entryType" is "user", this could hold a reference to the user Id - EntryCreated: The time the event occurred - Notes: Any optional notes to go along with the event
func GetEntriesByTypeMongo ¶
func GetEntriesByTypeMongo(entryType string, from time.Time, to time.Time, sort Sort, config *Config) ([]DataEntry, error)
GetEntriesByTypeMongo returns a slice of DataEntry objects by the specified filters
func (DataEntry) EntryReturnHelper ¶
EntryReturnHelper formats the return of a DataEntry object back to the client
type Sort ¶
Sort holds a structure of sort options
func ParseSort ¶
ParseSort parses the Gin context and takes in a default field to sort on. All other fields are set with sane defaults.
func (*Sort) ModifySortForMongo ¶
func (sort *Sort) ModifySortForMongo()
ModifySortForMongo takes a sort object and modifes it for use in the Mongo API