Documentation ¶
Overview ¶
Package structs supplies project-wide needed data structures, types and constants for the server and the command-line tool.
Package structs supplies project-wide needed data structures, types and constants for the server and the command-line tool.
Index ¶
Constants ¶
const RandomIDLength int = 10
RandomIDLength is the length of the ticket and mail ids.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CliErrMessage ¶
type CliErrMessage string
CliErrMessage defines different error messages printed when the command-line tool faces an error.
const ( TooManyInputs CliErrMessage = "too many successive wrong user inputs. Aborting program execution.\n" NoValidOption CliErrMessage = "not within the range of valid options" EmptyString CliErrMessage = "string is empty" InvalidEmail CliErrMessage = "not a valid email address" )
Various error messages for wrong user inputs
type CliMessage ¶
type CliMessage string
CliMessage defines different standard messages used by the command-line interface that are printed to the console.
const ( // RequestCommandInput is the message for requesting // a command input. RequestCommandInput CliMessage = "\nTo fetch Mails from the server, type '0'\n" + "To send an email to the server type '1'\n" + "To exit this program type '2'\n" + "Command: " // CommandNotAccepted is the error message if a command // is not recognized. CommandNotAccepted CliMessage = "Input not accepted, error: " // RequestEmailAddress it the message to prompt the user // for a valid e-mail input. RequestEmailAddress CliMessage = "Please enter your email address. It has to be valid.\nEmail address: " // RequestSubject is the message to prompt the user for // a ticket subject. RequestSubject CliMessage = "Please enter the subject line.\nSubject: " // RequestMessage is the message to prompt the user for // a ticket message. RequestMessage CliMessage = "Please enter the body of the message.\nMessage: " // RequestTicketID is the message to prompt the user for // an optional ticket id. RequestTicketID CliMessage = "If applicable please enter the ticket ID. If left empty, " + "a new ticket will be created.\nTicket ID (optional): " // To is the string for the output of the recipient of // an e-mail. To CliMessage = "To: " // Subject is the string for the output of the subject // of a ticket. Subject CliMessage = "Subject: " )
Messages of the command-line tool
type Command ¶
type Command int
Command represents a command-line interface command. This can be either Fetch, Submit or Exit.
type DataSingleTicket ¶
type DataSingleTicket struct { Session Session Ticket Ticket Tickets map[string]Ticket Users map[string]User }
DataSingleTicket holds the session and ticket data for a call to a single ticket.
type Entry ¶
type Entry struct { Date time.Time `json:"id"` FormattedDate string `json:"formattedDate"` User string `json:"user"` Text string `json:"text"` ReplyType string `json:"replyType"` }
Entry describes a single reply within a ticket.
type JSONMap ¶
type JSONMap map[string]interface{}
JSONMap is a type for mapping JSON keys to JSON values. It is mostly used inside the Mail API.
type LogConfig ¶
LogConfig defines the logging configuration for the server provided by the startup configuration flags.
type LogLevel ¶
type LogLevel int
LogLevel is a type that defines the level of logging. A high log level such as INFO means that more information and actions are logged to the console. A low log level suppresses the output of messages of a higher log level.
const ( // LevelInfo is the default log level (all messages // are logged). LevelInfo LogLevel = iota // LevelWarning logs warnings, errors and fatal errors. LevelWarning // LevelError only logs errors and fatal errors. LevelError // LevelFatal only logs fatal errors (not recommended). // Fatal errors are always logged. LevelFatal // LevelTestDebug is an additional log level used only // for debugging inside tests (not configurable). LevelTestDebug )
func AsLogLevel ¶
AsLogLevel converts a given log level string to a log level. If the log level string is not defined, the return value is -1.
type Mail ¶
type Mail struct { ID string `json:"id"` From string `json:"from"` To string `json:"to"` Subject string `json:"subject"` Message string `json:"message"` }
Mail struct holds the information for a received email in order to create new tickets or answers.
type ServerConfig ¶
type ServerConfig struct { // Port is the port the server is listening to. Port uint16 // Tickets is the directory in which // all tickets are stored. Tickets string // User is the path to the users.json file. Users string // Mails is the directory in which all // mails are stored. Mails string // Cert is the path to the SSL // Certificate file. Cert string // Key is the path to the SSL Key file. Key string // Web is the root directory of the server // where web resources are located. Web string }
ServerConfig is a struct to hold the config parameters provided on startup.
type SessionManager ¶
SessionManager holds a session and operates on a it.