func (app *App) Use(handle Middleware) *App {
	app.mds = append(app.mds, handle)
	return app
}
Use uses the given middleware `handle`.
package gear
import (
	"context"
	"encoding/json"
	"encoding/xml"
	"fmt"
	"io"
	"log"
	"net"
	"net/http"
	"os"
	"strings"
	"time"
)
type Middleware func(ctx *Context) error
type Handler interface {
	Serve(ctx *Context) error
}
type Sender interface {
	Send(ctx *Context, code int, data interface{}) error
}
type Renderer interface {
	Render(ctx *Context, w io.Writer, name string, data interface{}) error
}
type URLParser interface {
	Parse(val map[string][]string, body interface{}, tag string) error
}
type DefaultURLParser struct{}
func (d DefaultURLParser) Parse(val map[string][]string, body interface{}, tag string) error {
	return ValuesToStruct(val, body, tag)
}
type BodyParser interface {
	MaxBytes() int64
	Parse(buf []byte, body interface{}, mediaType, charset string) error
}
type DefaultBodyParser int64
func (d DefaultBodyParser) MaxBytes() int64 {
	return int64(d)
}
func (d DefaultBodyParser) Parse(buf []byte, body interface{}, mediaType, charset string) error {
	if len(buf) == 0 {
		return ErrBadRequest.WithMsg("request entity empty")
	}
	switch true {
	case strings.HasPrefix(mediaType, MIMEApplicationJSON), isLikeMediaType(mediaType, "json"):
		err := json.Unmarshal(buf, body)
		if err == nil {
			return nil
		}
		if ute, ok := err.(*json.UnmarshalTypeError); ok {
			if ute.Field == "" {  
				return fmt.Errorf("Unmarshal type error: expected=%v, got=%v, offset=%v",
					ute.Type, ute.Value, ute.Offset)
			}
			return fmt.Errorf("Unmarshal type error: field=%v, expected=%v, got=%v, offset=%v",
				ute.Field, ute.Type, ute.Value, ute.Offset)
		} else if se, ok := err.(*json.SyntaxError); ok {
			return fmt.Errorf("Syntax error: offset=%v, error=%v", se.Offset, se.Error())
		} else {
			return err
		}
	case strings.HasPrefix(mediaType, MIMEApplicationXML), isLikeMediaType(mediaType, "xml"):
		return xml.Unmarshal(buf, body)
	}
	return ErrUnsupportedMediaType.WithMsgf("unsupported media type: %s", mediaType)
}
type HTTPError interface {
	Error() string
	Status() int
}
type App struct {
	Server *http.Server
	mds    middlewares
	keys        []string
	renderer    Renderer
	sender      Sender
	bodyParser  BodyParser
	urlParser   URLParser
	compress    Compressible   
	timeout     time.Duration  
	serverName  string         
	logger      *log.Logger
	parseError  func(error) HTTPError
	renderError func(HTTPError) (code int, contentType string, body []byte)
	onerror     func(*Context, HTTPError)
	withContext func(*http.Request) context.Context
	settings    map[interface{}]interface{}
}
func New() *App {
	app := new(App)
	app.Server = new(http.Server)
	app.Server.ReadHeaderTimeout = 20 * time.Second
	app.Server.ReadTimeout = 60 * time.Second
	app.Server.WriteTimeout = 120 * time.Second
	app.Server.IdleTimeout = 90 * time.Second
	app.mds = make(middlewares, 0)
	app.settings = make(map[interface{}]interface{})
	env := os.Getenv("APP_ENV")
	if env == "" {
		env = "development"
	}
	app.Set(SetEnv, env)
	app.Set(SetServerName, "Gear/"+Version)
	app.Set(SetTrustedProxy, false)
	app.Set(SetBodyParser, DefaultBodyParser(2<<20))  
	app.Set(SetURLParser, DefaultURLParser{})
	app.Set(SetLogger, log.New(os.Stderr, "", 0))
	app.Set(SetGraceTimeout, 10*time.Second)
	app.Set(SetParseError, func(err error) HTTPError {
		return ParseError(err)
	})
	app.Set(SetRenderError, defaultRenderError)
	app.Set(SetOnError, func(ctx *Context, err HTTPError) {
		ctx.Error(err)
	})
	return app
}