mirror of
https://github.com/labstack/echo.git
synced 2024-11-28 08:38:39 +02:00
8ee864ae08
Signed-off-by: Vishal Rana <vr@labstack.com>
81 lines
1.4 KiB
Go
81 lines
1.4 KiB
Go
package engine
|
|
|
|
import (
|
|
"io"
|
|
"time"
|
|
|
|
"github.com/labstack/gommon/log"
|
|
)
|
|
|
|
type (
|
|
// Engine defines an interface for HTTP server.
|
|
Engine interface {
|
|
SetHandler(Handler)
|
|
SetLogger(*log.Logger)
|
|
Start()
|
|
}
|
|
|
|
// Request defines an interface for HTTP request.
|
|
Request interface {
|
|
TLS() bool
|
|
Scheme() string
|
|
Host() string
|
|
URI() string
|
|
URL() URL
|
|
Header() Header
|
|
// Proto() string
|
|
// ProtoMajor() int
|
|
// ProtoMinor() int
|
|
RemoteAddress() string
|
|
Method() string
|
|
Body() io.ReadCloser
|
|
FormValue(string) string
|
|
}
|
|
|
|
// Response defines an interface for HTTP response.
|
|
Response interface {
|
|
Header() Header
|
|
WriteHeader(int)
|
|
Write(b []byte) (int, error)
|
|
Status() int
|
|
Size() int64
|
|
Committed() bool
|
|
// SetWriter(io.Writer)
|
|
// Writer() io.Writer
|
|
}
|
|
|
|
// Header defines an interface for HTTP header.
|
|
Header interface {
|
|
Add(string, string)
|
|
Del(string)
|
|
Get(string) string
|
|
Set(string, string)
|
|
}
|
|
|
|
// URL defines an interface for HTTP request url.
|
|
URL interface {
|
|
SetPath(string)
|
|
Path() string
|
|
QueryValue(string) string
|
|
}
|
|
|
|
// Config defines engine configuration.
|
|
Config struct {
|
|
Address string
|
|
TLSCertfile string
|
|
TLSKeyfile string
|
|
ReadTimeout time.Duration
|
|
WriteTimeout time.Duration
|
|
}
|
|
|
|
Handler interface {
|
|
ServeHTTP(Request, Response)
|
|
}
|
|
|
|
HandlerFunc func(Request, Response)
|
|
)
|
|
|
|
func (h HandlerFunc) ServeHTTP(req Request, res Response) {
|
|
h(req, res)
|
|
}
|