I want to apply Basic authentication in golang using echo framework. I have following error :
"# command-line-arguments
.\main.go:44:29: cannot use func literal (type func(string, string, echo.Context) bool) as type middleware.BasicAuthValidator in argument to middleware.BasicAuth"
my code:
package main
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"net/http"
)
// main function
func main(){
e := echo.New()
g := e.Group("/home")
g.Use(middleware.BasicAuth(func (username, password string, c echo.Context) bool {
if(username=="iamsns" && password=="Iamsns355@"){
return true
} else {
return false
}
}))
g.POST("/login", getHome)
e.Start(":8008")
}