basicauth is a http basic auth middleware for tango
Go to file
Lunny Xiao d519c33aa8
All checks were successful
checks / check and test (push) Successful in 37s
Use actions instead of drone
2023-04-20 15:39:23 +08:00
.gitea/workflows Use actions instead of drone 2023-04-20 15:39:23 +08:00
README.md Use actions instead of drone 2023-04-20 15:39:23 +08:00
basicauth.go use go mod and moved to gitea.com 2019-10-31 20:51:54 +08:00
basicauth_test.go use go mod and moved to gitea.com 2019-10-31 20:51:54 +08:00
go.mod use go mod and moved to gitea.com 2019-10-31 20:51:54 +08:00
go.sum use go mod and moved to gitea.com 2019-10-31 20:51:54 +08:00

Basicauth

Middleware basicauth is a basic auth checker for Tango.

Installation

go get gitea.com/tango/basicauth

Simple Example

type AuthAction struct {}
func (a *AuthAction) Get() string {
    return "200"
}

func main() {
    tg := tango.Classic()
    tg.Use(basicauth.New(user, pass))
    tg.Get("/", new(AuthAction))
}

If you don't want some action to check auth, then

type NoAuthAction struct {
    basicauth.NoAuth
}
func (a *NoAuthAction) Get() string {
    return "200"
}

func main() {
    tg := tango.Classic()
    tg.Use(basicauth.New(user, pass))
    tg.Get("/", new(NoAuthAction))
}

will be ok.