mirror of https://github.com/gin-gonic/gin.git
separate type define (#975)
This commit is contained in:
parent
22fc0284e3
commit
d535fcd598
10
auth.go
10
auth.go
|
@ -13,15 +13,15 @@ import (
|
|||
// AuthUserKey is the cookie name for user credential in basic auth
|
||||
const AuthUserKey = "user"
|
||||
|
||||
type (
|
||||
// Accounts defines a key/value for user/pass list of authorized logins
|
||||
Accounts map[string]string
|
||||
authPair struct {
|
||||
type Accounts map[string]string
|
||||
|
||||
type authPair struct {
|
||||
Value string
|
||||
User string
|
||||
}
|
||||
authPairs []authPair
|
||||
)
|
||||
|
||||
type authPairs []authPair
|
||||
|
||||
func (a authPairs) searchCredential(authValue string) (string, bool) {
|
||||
if len(authValue) == 0 {
|
||||
|
|
|
@ -23,15 +23,13 @@ const (
|
|||
ErrorTypeNu = 2
|
||||
)
|
||||
|
||||
type (
|
||||
Error struct {
|
||||
type Error struct {
|
||||
Err error
|
||||
Type ErrorType
|
||||
Meta interface{}
|
||||
}
|
||||
|
||||
errorMsgs []*Error
|
||||
)
|
||||
type errorMsgs []*Error
|
||||
|
||||
var _ error = &Error{}
|
||||
|
||||
|
|
7
fs.go
7
fs.go
|
@ -9,14 +9,13 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
type (
|
||||
onlyfilesFS struct {
|
||||
type onlyfilesFS struct {
|
||||
fs http.FileSystem
|
||||
}
|
||||
neuteredReaddirFile struct {
|
||||
|
||||
type neuteredReaddirFile struct {
|
||||
http.File
|
||||
}
|
||||
)
|
||||
|
||||
// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally
|
||||
// in router.Static().
|
||||
|
|
9
gin.go
9
gin.go
|
@ -33,17 +33,17 @@ func (c HandlersChain) Last() HandlerFunc {
|
|||
return nil
|
||||
}
|
||||
|
||||
type (
|
||||
RoutesInfo []RouteInfo
|
||||
RouteInfo struct {
|
||||
type RouteInfo struct {
|
||||
Method string
|
||||
Path string
|
||||
Handler string
|
||||
}
|
||||
|
||||
type RoutesInfo []RouteInfo
|
||||
|
||||
// Engine is the framework's instance, it contains the muxer, middleware and configuration settings.
|
||||
// Create an instance of Engine, by using New() or Default()
|
||||
Engine struct {
|
||||
type Engine struct {
|
||||
RouterGroup
|
||||
delims render.Delims
|
||||
HTMLRender render.HTMLRender
|
||||
|
@ -93,7 +93,6 @@ type (
|
|||
// as url.Path gonna be used, which is already unescaped.
|
||||
UnescapePathValues bool
|
||||
}
|
||||
)
|
||||
|
||||
var _ IRouter = &Engine{}
|
||||
|
||||
|
|
|
@ -16,8 +16,7 @@ const (
|
|||
defaultStatus = 200
|
||||
)
|
||||
|
||||
type (
|
||||
ResponseWriter interface {
|
||||
type ResponseWriter interface {
|
||||
http.ResponseWriter
|
||||
http.Hijacker
|
||||
http.Flusher
|
||||
|
@ -40,12 +39,11 @@ type (
|
|||
WriteHeaderNow()
|
||||
}
|
||||
|
||||
responseWriter struct {
|
||||
type responseWriter struct {
|
||||
http.ResponseWriter
|
||||
size int
|
||||
status int
|
||||
}
|
||||
)
|
||||
|
||||
var _ ResponseWriter = &responseWriter{}
|
||||
|
||||
|
|
|
@ -11,13 +11,12 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
type (
|
||||
IRouter interface {
|
||||
type IRouter interface {
|
||||
IRoutes
|
||||
Group(string, ...HandlerFunc) *RouterGroup
|
||||
}
|
||||
|
||||
IRoutes interface {
|
||||
type IRoutes interface {
|
||||
Use(...HandlerFunc) IRoutes
|
||||
|
||||
Handle(string, string, ...HandlerFunc) IRoutes
|
||||
|
@ -37,13 +36,12 @@ type (
|
|||
|
||||
// RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix
|
||||
// and an array of handlers (middleware)
|
||||
RouterGroup struct {
|
||||
type RouterGroup struct {
|
||||
Handlers HandlersChain
|
||||
basePath string
|
||||
engine *Engine
|
||||
root bool
|
||||
}
|
||||
)
|
||||
|
||||
var _ IRouter = &RouterGroup{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue