middleware

package
v0.0.0-...-d799150 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPasswordHash

func CheckPasswordHash(password, hash string) bool

CheckPasswordHash compare raw password and hash

func HashPassword

func HashPassword(password string) (string, error)

HashPassword return a password hashed

Types

type BasicAuth

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

func NewBasicAuth

func NewBasicAuth(db *database.Psql) *BasicAuth

func (*BasicAuth) Apply

func (m *BasicAuth) Apply(w http.ResponseWriter, r *http.Request, rc *Rcontext)

Apply basic auth middleware it will check the basic auth header with user in db this middleware should be improved with check of session header if user are already logged

type Log

type Log struct {
	Logger *log.Logger
}

func NewLog

func NewLog(logtype string, out *os.File) *Log

NewLog return a new log instance who will write on file out or stdout

func (*Log) Apply

func (m *Log) Apply(w http.ResponseWriter, r *http.Request, rc *Rcontext)

Apply middleware print the request can be improve to log response is is set on postmdw

type Middleware

type Middleware interface {
	Apply(w http.ResponseWriter, r *http.Request, rc *Rcontext)
}

type Rcontext

type Rcontext struct {
	User       *vpgo.User
	StatusCode int
	Body       []byte
}

func NewRcontext

func NewRcontext() *Rcontext

Jump to

Keyboard shortcuts

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