mirror of https://github.com/gin-gonic/gin.git
separate type define (#975)
This commit is contained in:
parent
22fc0284e3
commit
d535fcd598
14
auth.go
14
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 {
|
||||
// Accounts defines a key/value for user/pass list of authorized logins
|
||||
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{}
|
||||
|
||||
|
|
11
fs.go
11
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().
|
||||
|
|
17
gin.go
17
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
|
||||
}
|
||||
}
|
||||
|
||||
// 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 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()
|
||||
type Engine struct {
|
||||
RouterGroup
|
||||
delims render.Delims
|
||||
HTMLRender render.HTMLRender
|
||||
|
@ -92,8 +92,7 @@ type (
|
|||
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
|
||||
// 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
|
||||
|
@ -38,14 +37,13 @@ type (
|
|||
|
||||
// Forces to write the http header (status code + headers).
|
||||
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
|
||||
|
@ -33,17 +32,16 @@ type (
|
|||
StaticFile(string, string) IRoutes
|
||||
Static(string, string) IRoutes
|
||||
StaticFS(string, http.FileSystem) IRoutes
|
||||
}
|
||||
}
|
||||
|
||||
// RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix
|
||||
// and an array of handlers (middleware)
|
||||
RouterGroup struct {
|
||||
// RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix
|
||||
// and an array of handlers (middleware)
|
||||
type RouterGroup struct {
|
||||
Handlers HandlersChain
|
||||
basePath string
|
||||
engine *Engine
|
||||
root bool
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
var _ IRouter = &RouterGroup{}
|
||||
|
||||
|
|
Loading…
Reference in New Issue