server

package
v0.0.0-...-5722567 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2023 License: Apache-2.0 Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHandle

func AddHandle(key, handle string, h http.HandlerFunc) error

AddHandle adds a hanler to the server. It can be called by plugins and similar.

func ConfigCookieSecure

func ConfigCookieSecure(secure bool)

ConfigCookieSecure sets whether future cookies will be secure. This method can not be called in parallel with any method of server which sets cookies.

func GetLogin

func GetLogin(key string, r *http.Request) (loggedin, admin bool)

GetLogin returns whether the user has a valid login and whether he is administrator.

func InitialiseServer

func InitialiseServer(config Config) error

InitialiseServer initialises the server. It needs to be called first before calling any other funtion of this package.

func RemoveLoginCookie

func RemoveLoginCookie(key string, rw http.ResponseWriter, r *http.Request)

RemoveLoginCookie removes all cookies for the given key. Please note that if the user can recreate the cookies on his machine, he can still log in.

func RunServer

func RunServer()

RunServer starts the actual server. It does nothing if a server is already started. It will return directly after the server is started.

func SetLoginCookie

func SetLoginCookie(key string, admin bool, rw http.ResponseWriter, r *http.Request) error

SetLoginCookie creates a valid login cookie for the given key.

func StopServer

func StopServer()

StopServer shuts the server down. It will do nothing if the server is not started. It will return after the shutdown is completed.

Types

type Config

type Config struct {
	Address          string
	PathDSGVO        string
	PathImpressum    string
	CookieTimeMinute int
}

Config holds all server configuration.

Jump to

Keyboard shortcuts

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