Documentation
¶
Index ¶
- Constants
- func ToFile(path string, config *APIConfig)
- type APIConfig
- func (c *APIConfig) FromEnv()
- func (c *APIConfig) GetEchoCORSConfig() middleware.CORSConfig
- func (c *APIConfig) GetEchoLoggerConfig() middleware.RequestLoggerConfig
- func (c *APIConfig) GetRateLimitConfig() middleware.RateLimiterConfig
- func (c *APIConfig) Logger() *e.ApiLogger
- func (c *APIConfig) ServerAddress() string
- func (c *APIConfig) ShowBrand()
- type AuthConfig
- type CorsConfig
- type CurriculumTypeConfig
- type ExamEvaluationTypeConfig
- type GradeTypeConfig
- type RateLimitConfig
- type RoleConfig
Constants ¶
const ( // Roles ROLE_COURSEADMIN uint = 1 ROLE_FIELDMANAGER uint = 2 ROLE_TEACHER uint = 3 ROLE_STUDENT uint = 4 // Grade types GRADETYPE_NONE uint = 1 GRADETYPE_NOTE uint = 2 GRADETYPE_PERCENT uint = 3 )
const VERSION string = "0.8.1"
Version of the API
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIConfig ¶
type APIConfig struct {
Host string `yaml:"host"` // Host is the address of the server
Port int `yaml:"port"` // Port is the port of the server
AuthConfig AuthConfig `yaml:"auth"` // AuthConfig is the configuration for authentication
AutoMigrate bool `yaml:"autoMigrate"` // AutoMigrate is a flag to determine if the database should be migrated automatically
Connect bool `yaml:"connect"` // Connect is a flag to determine if the database should be connected automatically
DBConnectionStr string `yaml:"dbConnectionStr"` // DBConnectionStr is the connection string for the database
AllowedDomains []string `yaml:"allowedDomains"` // AllowedDomains is the list of allowed domains for new users
ExamTypes []string `yaml:"examTypes"` // ExamTypes is the list of exam types
ExamEvaluationTypes []ExamEvaluationTypeConfig `yaml:"examEvaluationTypes"` // EvalTypes is the list of evaluation types
GradeTypes []GradeTypeConfig `yaml:"gradeTypes"` // GradeTypes is the list of grade types
States []string `yaml:"states"` // States is the list of states
CurriculumTypes []CurriculumTypeConfig `yaml:"curriculumTypes"` // CurriculumTypes is the list of curriculum types
Roles []RoleConfig `yaml:"roles"` // Roles is the list of roles
MockData bool `yaml:"mockData"` // Add MockData at startup
Cors CorsConfig `yaml:"cors"` // Cors is the configuration for CORS
MaxBodySize string `yaml:"maxBodySize"` // BodySize is the maximum size of the request body
RateLimit RateLimitConfig `yaml:"rateLimit"` // RateLimit is the configuration for rate limiting
LogLevel string `yaml:"logLevel"` // LogLevel is the preferred log level
// contains filtered or unexported fields
}
APIConfig is used to define the configuration of the API
func FromFile ¶
Loads the configuration from a file Attempts to write default configuration to file if file does not exist
func NewAPIConfig ¶
func NewAPIConfig() *APIConfig
Returns a new configuration with default values This is used to create the config file if it does not exist
func (*APIConfig) FromEnv ¶
func (c *APIConfig) FromEnv()
Overwrites the current configuration with environment variables
func (*APIConfig) GetEchoCORSConfig ¶
func (c *APIConfig) GetEchoCORSConfig() middleware.CORSConfig
Returns the echo CORS configuration based on the API configuration
func (*APIConfig) GetEchoLoggerConfig ¶
func (c *APIConfig) GetEchoLoggerConfig() middleware.RequestLoggerConfig
Returns the echo logger configuration based on the API configuration
func (*APIConfig) GetRateLimitConfig ¶
func (c *APIConfig) GetRateLimitConfig() middleware.RateLimiterConfig
Returns the rate limiter configuration based on the API configuration
func (*APIConfig) ServerAddress ¶
Returns the server address as a string
type AuthConfig ¶
type AuthConfig struct {
Enabled bool `yaml:"enabled"` // Enabled is a flag to determine if authentication is enabled
OAuthKeyDiscoveryURL string `yaml:"oAuthKeyDiscoveryURL"` // OAuthKeyDiscoveryURL is the URL to discover the OAuth keys
}
Configuration for Authentication
type CorsConfig ¶
type CorsConfig struct {
AllowedOrigins []string `yaml:"allowedOrigins"` // AllowedOrigins is the list of allowed origins
AllowedHeaders []string `yaml:"allowedHeaders"` // AllowedHeaders is the list of allowed headers
}
Configuration for CORS
type CurriculumTypeConfig ¶
type CurriculumTypeConfig struct {
Description string `yaml:"description"`
DurationYears uint `yaml:"durationyears"`
}
Predefined curriculum types
type ExamEvaluationTypeConfig ¶
type ExamEvaluationTypeConfig struct {
Code string `yaml:"code"` // code is the code of the evaluation type
Description string `yaml:"description"` // description is the description of the evaluation type
}
Predefined exam evaluation types
type GradeTypeConfig ¶
type RateLimitConfig ¶
type RateLimitConfig struct {
Burst int `yaml:"burst"` // Burst is the maximum number of requests that can be made in a second (RPS)
Rate int `yaml:"rate"` // Rate is the usual number of requests that can be made in a second (RPS)
Expiry int `yaml:"expiry"` // Expiry is the time in seconds until the rate limit is reset
}
type RoleConfig ¶
type RoleConfig struct {
Id uint `yaml:"id"` // Id of the role
Name string `yaml:"name"` // Name of the role
ClaimName string `yaml:"claimName"` // Name of the claim in the JWT
}
Configuration for a role