Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIRootService ¶
type APIRootService struct { BaseService Collections struct { Enabled bool // User defined in configuration file ReadAccess []string // User defined in configuration file. WriteAccess []string // User defined in configuration file. } }
APIRootService - This struct represents an instance of an API Root server. If someone tries to set the 'path' directive in the configuration file it will just get overwritten in code. ReadAccess - This is a list of collection resource IDs that may have GET access at the API Root level WriteAccess - This is a list of collection resource IDs that may have POST access at the API Root level
type BaseService ¶
type BaseService struct { Enabled bool // User defined in configuration file Path string // User defined in configuration file ResourceID string // User defined in configuration file HTML HTMLConfig // User defined in configuration file or set in the verify scripts. }
BaseService - This struct represents the common properties between the Discovery and API-Root services.
Path - The URL path for this service Enabled - Is this service enabled ResourceID - A unique ID for the resource that this service is using ResourcePath - The actual full URL path for the resource, used for the handler to know where to listen. HTML - The configuration for generating HTML output
type DiscoveryService ¶
type DiscoveryService struct {
BaseService
}
DiscoveryService - This struct represents an instance of a Discovery server. If someone tries to set the 'resourcepath' directive in the configuration file it will get overwritten in code.
type HTMLConfig ¶
type HTMLConfig struct { Enabled JSONbool // User defined in configuration file or set in verifyHTMLConfig() TemplateDir JSONstring // User defined in configuration file or set in verifyHTMLConfig() TemplateFiles struct { Discovery JSONstring // User defined in configuration file or set in verifyHTMLConfig() APIRoot JSONstring Collections JSONstring Collection JSONstring Objects JSONstring Versions JSONstring Manifest JSONstring } FullTemplatePath string // Set in verifyHTMLConfig(), this is the full path to template files }
HTMLConfig - This struct holds the configuration elements for generating HTML output. This is used at the top level of the configuration file as well as in each individual service. This means individual services can have a different HTML configuration. I needed to setup my own types for JSON boolean and strings since leaving it blank at a child level, would have equaled "false" or "". This would have been equivalent to turning it off, which is not what is wanted. Leaving it blank would mean to inherit from the parent. But since Go is a strictly typed language, you need to create a type that can handle that case.
Enabled - Is HTML enabled for this service TemplateDir - The location of the template files relative to the base of the application (prefix) FullTemplatePath - The full path of the template directory (prefix + TemplateDir) TemplateFiles - The HTML template filenames in the template directory for the following services
type JSONbool ¶
JSONbool - A boolean type for use with JSON that will track if a value is undefined or set to null.
func (*JSONbool) UnmarshalJSON ¶
UnmarshalJSON - This method defines the unmarshal process for the JSONbool type. We need to track of the value was set, set to null, or actually set to true or false. This is important since not being set is not the same thing has false or true. This comes into play when you need to inherit some previous higher level setting. Meaning if you set a property higher up in the configuration to true or false, then you want that to be cascaded down and without doing this, it does not work.
type JSONstring ¶
JSONstring - A string type for use with JSON that will track if a value is undefined or set to null.
func (*JSONstring) UnmarshalJSON ¶
func (s *JSONstring) UnmarshalJSON(data []byte) error
UnmarshalJSON - This method will handle the unmarshalling of content for the JSONbool type
type ServerConfig ¶
type ServerConfig struct { Router *mux.Router Logger *log.Logger Global struct { Prefix string Listen string Protocol string TLSDir string TLSKey string TLSCrt string DbConfig bool DbType string DbFile string ServerRecordLimit int } HTML struct { HTMLConfig } Logging struct { Enabled bool Level int LogFile string } DiscoveryServer struct { Enabled bool Services []DiscoveryService } `json:"discovery_server,omitempty"` APIRootServer struct { Enabled bool Services []APIRootService } `json:"apiroot_server,omitempty"` DiscoveryResources map[string]discovery.Discovery `json:"discovery_resources,omitempty"` // The key in the map is the ResourceID APIRootResources map[string]apiroot.APIRoot `json:"apiroot_resources,omitempty"` // The key in the map is the ResourceID CollectionResources map[string]collections.Collection `json:"collection_resources,omitempty"` // The key in the map is the ResourceID }
ServerConfig - This type defines the configuration for the entire server.
func New ¶
func New(logger *log.Logger, filename string) (ServerConfig, error)
New - This function will load the current configuration from a file, verify that the configuration is correct, and then return a ServerConfig type.
func (*ServerConfig) Verify ¶
func (c *ServerConfig) Verify() error
Verify - This method will verify that the configuration file has what it needs. TODO finish fleshing this out