mirror of
https://github.com/labstack/echo.git
synced 2024-11-28 08:38:39 +02:00
Fixed #389
This commit is contained in:
parent
94d0feea1b
commit
7263e50e10
@ -13,7 +13,7 @@ import (
|
||||
|
||||
type (
|
||||
Server struct {
|
||||
config *engine.Config
|
||||
config engine.Config
|
||||
handler engine.Handler
|
||||
logger *log.Logger
|
||||
pool *Pool
|
||||
@ -29,12 +29,12 @@ type (
|
||||
)
|
||||
|
||||
func New(addr string) *Server {
|
||||
c := &engine.Config{Address: addr}
|
||||
c := engine.Config{Address: addr}
|
||||
return NewFromConfig(c)
|
||||
}
|
||||
|
||||
func NewFromTLS(addr, certfile, keyfile string) *Server {
|
||||
c := &engine.Config{
|
||||
c := engine.Config{
|
||||
Address: addr,
|
||||
TLSCertfile: certfile,
|
||||
TLSKeyfile: keyfile,
|
||||
@ -42,7 +42,7 @@ func NewFromTLS(addr, certfile, keyfile string) *Server {
|
||||
return NewFromConfig(c)
|
||||
}
|
||||
|
||||
func NewFromConfig(c *engine.Config) (s *Server) {
|
||||
func NewFromConfig(c engine.Config) (s *Server) {
|
||||
s = &Server{
|
||||
config: c,
|
||||
pool: &Pool{
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
type (
|
||||
Server struct {
|
||||
*http.Server
|
||||
config *engine.Config
|
||||
config engine.Config
|
||||
handler engine.Handler
|
||||
logger *log.Logger
|
||||
pool *Pool
|
||||
@ -27,12 +27,12 @@ type (
|
||||
)
|
||||
|
||||
func New(addr string) *Server {
|
||||
c := &engine.Config{Address: addr}
|
||||
c := engine.Config{Address: addr}
|
||||
return NewFromConfig(c)
|
||||
}
|
||||
|
||||
func NewFromTLS(addr, certfile, keyfile string) *Server {
|
||||
c := &engine.Config{
|
||||
c := engine.Config{
|
||||
Address: addr,
|
||||
TLSCertfile: certfile,
|
||||
TLSKeyfile: keyfile,
|
||||
@ -40,7 +40,7 @@ func NewFromTLS(addr, certfile, keyfile string) *Server {
|
||||
return NewFromConfig(c)
|
||||
}
|
||||
|
||||
func NewFromConfig(c *engine.Config) (s *Server) {
|
||||
func NewFromConfig(c engine.Config) (s *Server) {
|
||||
s = &Server{
|
||||
Server: new(http.Server),
|
||||
config: c,
|
||||
|
@ -22,7 +22,7 @@ const (
|
||||
//
|
||||
// For valid credentials it calls the next handler.
|
||||
// For invalid credentials, it sends "401 - Unauthorized" response.
|
||||
func BasicAuth(fn BasicAuthFunc, options ...*BasicAuthOptions) echo.MiddlewareFunc {
|
||||
func BasicAuth(fn BasicAuthFunc, options ...BasicAuthOptions) echo.MiddlewareFunc {
|
||||
return func(next echo.Handler) echo.Handler {
|
||||
return echo.HandlerFunc(func(c echo.Context) error {
|
||||
auth := c.Request().Header().Get(echo.Authorization)
|
||||
@ -36,7 +36,7 @@ func BasicAuth(fn BasicAuthFunc, options ...*BasicAuthOptions) echo.MiddlewareFu
|
||||
if cred[i] == ':' {
|
||||
// Verify credentials
|
||||
if fn(cred[:i], cred[i+1:]) {
|
||||
return nil
|
||||
return next.Handle(c)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ Hello, World! on the page.
|
||||
|
||||
### Next?
|
||||
- Browse [recipes](/recipes/hello-world)
|
||||
- Head over to [guide](/guide/installation")
|
||||
- Head over to [guide](/guide/installation)
|
||||
|
||||
## Contribute
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user