server

package
v0.7.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DummyMiddleware

func DummyMiddleware(next http.HandlerFunc) http.HandlerFunc

DummyMiddleware is middleware that does nothing. It is used to wrap the go-chi/httprate limiter around a handler.

func Run

func Run(cfg *RunCfg) (err error)

Run starts the HTTP server on the specified port and connects to the specified database.

Types

type Credentials

type Credentials struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

Credentials represents the user credentials.

type CredentialsChange

type CredentialsChange struct {
	OldPassword string `json:"old"`
	NewPassword string `json:"new"`
}

CredentialsChange represents the user credentials for changing passwords.

type CredentialsReset

type CredentialsReset struct {
	Code     string `json:"code"`
	Email    string `json:"email"`
	Password string `json:"password"`
}

CredentialsReset represents the user credentials for resetting password.

type DatabaseBackend

type DatabaseBackend string

DatabaseBackend is the type of database backend to use.

type GradeData

type GradeData struct {
	CourseCode      string  `json:"code"`
	ProfUUID        string  `json:"uuid"`
	GradeTeaching   float32 `json:"teaching"`
	GradeCoursework float32 `json:"coursework"`
	GradeLearning   float32 `json:"learning"`
}

GradeData contains data needed to grade a course.

type Handler

type Handler struct {
	Handlers []struct {
		Path     string `json:"path"`
		PathType string `json:"pathType"`
		Handler  string `json:"handler"`
		Limiter  string `json:"limiter"`
		Method   string `json:"method"`
	} `json:"handlers"`
}

Handler holds data for a handler.

type HandlerInfo

type HandlerInfo struct {
	// contains filtered or unexported fields
}

HandlerInfo represents a struct containing information about an HTTP handler.

type LogLevel

type LogLevel string

LogLevel is the type of log level.

type PathType

type PathType int

PathType is the type of the path (admin, user, public).

type RunCfg added in v0.6.0

type RunCfg struct {
	Port               string          // Port on which the server will run.
	DbUrl              string          // Path to the SQLite database file.
	DbBackend          DatabaseBackend // Database backend type.
	CacheDbUrl         string          // URL to the redis cache database.
	CacheTtl           int             // Time-to-live of the cache in seconds.
	UsersDbPath        string          // Path to the users BOLT database file.
	AllowedOrigins     []string        // List of allowed origins for CORS.
	AllowedMailDomains []string        // List of allowed mail domains for registering with the service.
	PasswordResetUrl   string          // URL to the password reset website page.
	NoMail             bool            // Whether to enable mail services.
	SmtpEnvPath        string          // Path to the .env file containing SMTP configuration.
	UseSmtp            bool            // Whether to use SMTP (false for SMTPS).
	UseHttp            bool            // Whether to use HTTP (false for HTTPS).
	HandlersFilePath   string          // Handler config json file.
	CertFilePath       string          // Path to the certificate file (required for HTTPS).
	KeyFilePath        string          // Path to the key file (required for HTTPS).
	CookieTimeout      int             // Duration in minute after which a session cookie expires.
	CodeValidityMinute int             // Duration in minute after which a code is invalid.
	CodeLength         int             // Length of generated codes.
	MinPasswordScore   int             // Minimum acceptable score of a password scores computed by zxcvbn.
	LogLevel           LogLevel        // Log level.
}

RunCfg defines the server's configuration.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL