2016-01-29 09:46:11 +02:00
|
|
|
package engine
|
|
|
|
|
2016-02-05 00:40:08 +02:00
|
|
|
import (
|
|
|
|
"io"
|
|
|
|
"time"
|
2016-02-10 03:16:46 +02:00
|
|
|
|
2016-03-06 19:52:32 +02:00
|
|
|
"github.com/labstack/gommon/log"
|
2016-02-05 00:40:08 +02:00
|
|
|
)
|
2016-01-29 09:46:11 +02:00
|
|
|
|
|
|
|
type (
|
|
|
|
Engine interface {
|
2016-03-08 18:14:25 +02:00
|
|
|
SetHandler(Handler)
|
2016-03-06 19:52:32 +02:00
|
|
|
SetLogger(*log.Logger)
|
2016-01-29 09:46:11 +02:00
|
|
|
Start()
|
|
|
|
}
|
|
|
|
|
|
|
|
Request interface {
|
2016-02-23 07:13:08 +02:00
|
|
|
TLS() bool
|
2016-02-23 07:26:36 +02:00
|
|
|
Scheme() string
|
2016-02-09 18:12:37 +02:00
|
|
|
Host() string
|
2016-02-09 02:48:03 +02:00
|
|
|
URI() string
|
|
|
|
URL() URL
|
2016-01-29 09:46:11 +02:00
|
|
|
Header() Header
|
|
|
|
// Proto() string
|
|
|
|
// ProtoMajor() int
|
|
|
|
// ProtoMinor() int
|
|
|
|
RemoteAddress() string
|
|
|
|
Method() string
|
|
|
|
Body() io.ReadCloser
|
|
|
|
FormValue(string) string
|
2016-02-09 02:48:03 +02:00
|
|
|
Object() interface{}
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Response interface {
|
|
|
|
Header() Header
|
|
|
|
WriteHeader(int)
|
|
|
|
Write(b []byte) (int, error)
|
|
|
|
Status() int
|
|
|
|
Size() int64
|
|
|
|
Committed() bool
|
2016-02-05 00:40:08 +02:00
|
|
|
SetWriter(io.Writer)
|
|
|
|
Writer() io.Writer
|
2016-02-09 02:48:03 +02:00
|
|
|
Object() interface{}
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Header interface {
|
|
|
|
Add(string, string)
|
|
|
|
Del(string)
|
|
|
|
Get(string) string
|
|
|
|
Set(string, string)
|
2016-02-21 00:04:09 +02:00
|
|
|
Object() interface{}
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
URL interface {
|
|
|
|
SetPath(string)
|
|
|
|
Path() string
|
|
|
|
QueryValue(string) string
|
2016-02-21 00:04:09 +02:00
|
|
|
Object() interface{}
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Config struct {
|
2016-02-05 00:40:08 +02:00
|
|
|
Address string
|
|
|
|
TLSCertfile string
|
|
|
|
TLSKeyfile string
|
2016-02-23 08:24:56 +02:00
|
|
|
ReadTimeout time.Duration
|
|
|
|
WriteTimeout time.Duration
|
2016-01-29 09:46:11 +02:00
|
|
|
}
|
2016-03-08 18:14:25 +02:00
|
|
|
|
|
|
|
Handler interface {
|
|
|
|
ServeHTTP(Request, Response)
|
|
|
|
}
|
|
|
|
|
|
|
|
HandlerFunc func(Request, Response)
|
2016-01-29 09:46:11 +02:00
|
|
|
)
|
2016-03-08 18:14:25 +02:00
|
|
|
|
|
|
|
func (h HandlerFunc) ServeHTTP(req Request, res Response) {
|
|
|
|
h.ServeHTTP(req, res)
|
|
|
|
}
|