weblib

package module
v0.0.0-...-4b4f01a Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2020 License: Apache-2.0 Imports: 10 Imported by: 25

README

weblib

golang http serve library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File2WebOut

func File2WebOut(w http.ResponseWriter, outfile string) error

func GetFloat64ByName

func GetFloat64ByName(
	name string, errorval float64, w http.ResponseWriter, r *http.Request) float64

func GetIntByName

func GetIntByName(
	name string, errorval int, w http.ResponseWriter, r *http.Request) int

func GetPage

func GetPage(w http.ResponseWriter, r *http.Request) int

func GetStringByName

func GetStringByName(
	name string, errorval string, w http.ResponseWriter, r *http.Request) string

func PageMid

func PageMid(
	listLen, pagesize int,
	urlStr string,
	w http.ResponseWriter, r *http.Request)

func ServeJSON2HTTP

func ServeJSON2HTTP(obj interface{}, w http.ResponseWriter) error

func SetFresh

func SetFresh(w http.ResponseWriter, r *http.Request) error

func Use

func Use(
	h http.HandlerFunc,
	middleware ...func(http.HandlerFunc) http.HandlerFunc) http.HandlerFunc

func WebFormBegin

func WebFormBegin(title string, w http.ResponseWriter, r *http.Request)

func WebFormEnd

func WebFormEnd(w http.ResponseWriter, r *http.Request)

func WebLog

func WebLog(logFilename string, size int64, w http.ResponseWriter, r *http.Request) error

Types

type AuthData

type AuthData struct {
	Realm         string
	Name2Password map[string]string
	ActionNameMap map[[2]string]bool
	ActionMap     map[string]bool
}

func NewAuthData

func NewAuthData(realm string) *AuthData

func (*AuthData) AddAction

func (ad *AuthData) AddAction(action string) error

func (*AuthData) AddAllActionName

func (ad *AuthData) AddAllActionName(name string) error

func (*AuthData) CheckAction

func (ad *AuthData) CheckAction(action, name string) error

func (*AuthData) CheckLogin

func (ad *AuthData) CheckLogin(name, password string) error

func (*AuthData) GetBasicAuthRealmString

func (ad *AuthData) GetBasicAuthRealmString() string

func (*AuthData) ReLoadActionName

func (ad *AuthData) ReLoadActionName(data [][2]string) error

action name list

func (*AuthData) ReLoadUserData

func (ad *AuthData) ReLoadUserData(data [][2]string) error

name password list

func (AuthData) String

func (ad AuthData) String() string

type AuthMux

type AuthMux struct {
	*http.ServeMux

	AuthAction   []string
	NoAuthAction []string
	// contains filtered or unexported fields
}

func NewAuthMux

func NewAuthMux(authdata *AuthData, l loggerI) *AuthMux

func (*AuthMux) Auth

func (am *AuthMux) Auth(pattern string, handler http.HandlerFunc) http.HandlerFunc

func (*AuthMux) HandleFuncAuth

func (am *AuthMux) HandleFuncAuth(pattern string, handler func(http.ResponseWriter, *http.Request))

func (AuthMux) String

func (am AuthMux) String() string

type BasicAuth

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

func NewBasicAuth

func NewBasicAuth(realm string, name string, password string) *BasicAuth

func (*BasicAuth) Auth

Leverages nemo's answer in http://stackoverflow.com/a/21937924/556573

type IAuthMuxHandle

type IAuthMuxHandle interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	HandleFuncAuth(pattern string, handler func(http.ResponseWriter, *http.Request))
}
type IMuxHandle interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

type NoAuth

type NoAuth struct {
}

func NewNoAuth

func NewNoAuth() *NoAuth

func (*NoAuth) Auth

func (na *NoAuth) Auth(h http.HandlerFunc) http.HandlerFunc

Directories

Path Synopsis
Package webprofile add profile to web
Package webprofile add profile to web

Jump to

Keyboard shortcuts

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