middleware

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: GPL-3.0 Imports: 3 Imported by: 0

README

BasicAuth middleware

package main

// type Authenticate func(user, pwd string) (int, error)
func myAuthenticator(user, pwd string) (int, error) {
  // log in with back-end
  // if login fails you should return a http response code and an err
  
  //Login OK
  return -1, nil
}

func main() {
	//stuffs
  ba := middleware.BasicAuth(myAuthenticator)
  routebuilder.New(GET).
    Middleware(ba).
    Path("/api/secret").
    Build()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Audith added in v1.1.0

func BasicAuditor added in v1.1.0

func BasicAuditor(a Auditor) routebuilder.Middleware

func BasicAuth

func BasicAuth(auth Authenticate) routebuilder.Middleware

func CustomHeader

func CustomHeader(k, v string) func(h http.HandlerFunc) http.HandlerFunc

func Headers

func Headers(headers map[string]string) func(h http.HandlerFunc) http.HandlerFunc

Types

type Auditor added in v1.1.0

type Auditor interface {
	BasicAudit(user, path, query string) error
}

type Authenticate

type Authenticate func(user, pwd string) (int, error)

type CustomAuditor added in v1.1.0

type CustomAuditor interface {
	CollectAuditInfo(h http.Header)
	DoAudit(info map[string]string)
}

Jump to

Keyboard shortcuts

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