utils

package
v0.0.0-...-6136325 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareHash

func CompareHash(hash string, inString string) (bool, error)

CompareHash compare a argon2 hash string with a plain string

func DecodeBody

func DecodeBody(r *http.Request, v interface{}) error

DecodeBody a HTTP Body

func GenerateHash

func GenerateHash(inString string) string

GenerateHash for salted passwords with argon2

func GetPageTemplate

func GetPageTemplate(basePath string, viewsPath string) *template.Template

GetPageTemplate to Writer

func GetPlainTemplate

func GetPlainTemplate(basePath string, viewsPath string) *template.Template

GetPlainTemplate to Writer

func RandSeq

func RandSeq(n int) string

RandSeq generates a random string to serve as dummy data

func WriteContentType

func WriteContentType(w http.ResponseWriter, cType string)

WriteContentType to Response Header

func WriteData

func WriteData(w http.ResponseWriter, data []byte)

WriteData to Response with Status OK

func WriteError

func WriteError(w http.ResponseWriter, err error)

WriteError to Response as JSON with Status 500

func WriteJSON

func WriteJSON(w http.ResponseWriter, v interface{})

WriteJSON to Response

func WriteRedirect

func WriteRedirect(w http.ResponseWriter, path string)

WriteRedirect to Response Header

func WriteResultOrError

func WriteResultOrError(w http.ResponseWriter, v interface{}, err error)

WriteResultOrError to Response

func WriteStatusConfict

func WriteStatusConfict(w http.ResponseWriter)

WriteStatusConfict to Response Header

func WriteStatusError

func WriteStatusError(w http.ResponseWriter)

WriteStatusError to Response Header

func WriteStatusForbidden

func WriteStatusForbidden(w http.ResponseWriter)

WriteStatusForbidden to Response Header

func WriteStatusNotFound

func WriteStatusNotFound(w http.ResponseWriter)

WriteStatusNotFound to Response Header

func WriteStatusOK

func WriteStatusOK(w http.ResponseWriter)

WriteStatusOK to Response Header

func WriteText

func WriteText(w http.ResponseWriter, text string)

WriteText to Response with Status OK

Types

type ContextKeyType

type ContextKeyType struct{}

ContextKeyType for Request Context

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

func NewNavBuilder

func NewNavBuilder() NavBuilder
func (nb *NavBuilder) AddElement(title string, link string, icon string)
func (nb *NavBuilder) GetNavigation(activeTitle string) map[string]interface{}

type ViewData

type ViewData map[string]interface{}

ViewData is the Type for the Views

func GetViewData

func GetViewData(r *http.Request) ViewData

GetViewData for the RenderView

Jump to

Keyboard shortcuts

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