From 5c330580382d1ba3474d3da68f7cf795be3d30ab Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Sat, 5 Nov 2022 08:44:37 +0100 Subject: [PATCH] updated documentation --- auth/doc.go | 3 +++ constants/auth.go | 14 ++++++++++++++ constants/doc.go | 2 ++ doc.go | 2 ++ funcs/doc.go | 2 ++ menus/doc.go | 2 ++ middleware/db/db.go | 3 ++- middleware/doc.go | 2 ++ middleware/middleware.go | 2 +- modules/saml/doc.go | 2 ++ site.go | 4 ++++ templates/templates.go | 3 ++- 12 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 auth/doc.go create mode 100644 constants/auth.go create mode 100644 constants/doc.go create mode 100644 doc.go create mode 100644 funcs/doc.go create mode 100644 menus/doc.go create mode 100644 middleware/doc.go create mode 100644 modules/saml/doc.go diff --git a/auth/doc.go b/auth/doc.go new file mode 100644 index 0000000..8ee7cfe --- /dev/null +++ b/auth/doc.go @@ -0,0 +1,3 @@ +// Package auth is for the abstraction of the authentication method. +// this enables the application developer to seperate the authentication from the authentication itself. +package auth diff --git a/constants/auth.go b/constants/auth.go new file mode 100644 index 0000000..98ad325 --- /dev/null +++ b/constants/auth.go @@ -0,0 +1,14 @@ +package constants + +// AccountConstant is an type for easier linting. +type AccountConstant string + +// These are Constants to save specific attributes in single points of use. +const ( + // AccountID is the ID of the session. Prefferably it should be an UUIDv4 to mitigate security errors. + AccountID AccountConstant = "jti" + // AccountAnon is to identify Sessions as Anonymous sessions. + AccountAnon AccountConstant = "anon" + // AccountUser is an attribute that identifies the user with an string that is unique for the user, for Example the username. + AccountUser AccountConstant = "uid" +) diff --git a/constants/doc.go b/constants/doc.go new file mode 100644 index 0000000..7423026 --- /dev/null +++ b/constants/doc.go @@ -0,0 +1,2 @@ +// Package constants provides static aliases when an value from an enum is required +package constants diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..f235ecc --- /dev/null +++ b/doc.go @@ -0,0 +1,2 @@ +// Package httpserver provides developers with an HTTP-Server that route parts of the site on different domains and is configurable after the build +package httpserver diff --git a/funcs/doc.go b/funcs/doc.go new file mode 100644 index 0000000..d13ed38 --- /dev/null +++ b/funcs/doc.go @@ -0,0 +1,2 @@ +// Package funcs provides fome functions that for special cases +package funcs diff --git a/menus/doc.go b/menus/doc.go new file mode 100644 index 0000000..fc3f930 --- /dev/null +++ b/menus/doc.go @@ -0,0 +1,2 @@ +// Package menus provides an abstraction for providing an global menu that covers multiple sites +package menus diff --git a/middleware/db/db.go b/middleware/db/db.go index 7037075..3e76553 100644 --- a/middleware/db/db.go +++ b/middleware/db/db.go @@ -1,3 +1,4 @@ +// Package db is an middleware that manages multiple database pools and provides applications with an way to access the database package db import ( @@ -31,7 +32,7 @@ type Middleware struct { lock sync.Mutex } -//NewMiddleware return an initialized Middleware Object. +// NewMiddleware return an initialized Middleware Object. func NewMiddleware() *Middleware { return &Middleware{ databases: make(map[string]*pgxpool.Pool), diff --git a/middleware/doc.go b/middleware/doc.go new file mode 100644 index 0000000..2c8a7ba --- /dev/null +++ b/middleware/doc.go @@ -0,0 +1,2 @@ +// Package middleware provides some middleware +package middleware diff --git a/middleware/middleware.go b/middleware/middleware.go index 04385ac..1e67acb 100644 --- a/middleware/middleware.go +++ b/middleware/middleware.go @@ -11,7 +11,7 @@ import ( "go.sebtobie.de/httpserver/constants" ) -// LogMiddleware is an middleware to log requests to phuslu/log and catches panics. +// LogMiddleware is an middleware to log requests to rs/zerolog and catches panics. // If it is added multiple times, only the first time sends entries to the log. func LogMiddleware(c *gin.Context) { if _, exists := c.Get("xid"); exists { diff --git a/modules/saml/doc.go b/modules/saml/doc.go new file mode 100644 index 0000000..5f821b6 --- /dev/null +++ b/modules/saml/doc.go @@ -0,0 +1,2 @@ +// Package saml provides an Authentication Handler for authenticating over SAML +package saml diff --git a/site.go b/site.go index ec87c43..d1a53a9 100644 --- a/site.go +++ b/site.go @@ -11,13 +11,17 @@ type Site interface { // ConfigSite is for sites that have to be configured type ConfigSite interface { Site + // Defaults returns the default values for the configuration Defaults() SiteConfig + // Setup configures the Site with the read configuration. + // For the order how the methods are called refer to [Server.Setup] Setup(SiteConfig) error } // TeardownSite is for sites that require to do steps before shutdown type TeardownSite interface { Site + // Teardown is called before shutting down the server. Its for gracefully shutdowns of goroutines or longstanding connections Teardown() } diff --git a/templates/templates.go b/templates/templates.go index 86a3e3b..08f5c7a 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -1,3 +1,4 @@ +// Package templates helps sites to manage their templates package templates import ( @@ -19,7 +20,7 @@ var ( _ pongo2.TemplateLoader = &EmptyLoader{} ) -//TemplateSite is an interface that is for storing templates. +// TemplateSite is an interface that is for storing templates. type TemplateSite interface { Templates() pongo2.TemplateLoader }