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
|
// AuthUserKey is the cookie name for user credential in basic auth
|
||||||
const AuthUserKey = "user"
|
const AuthUserKey = "user"
|
||||||
|
|
||||||
type (
|
// Accounts defines a key/value for user/pass list of authorized logins
|
||||||
// Accounts defines a key/value for user/pass list of authorized logins
|
type Accounts map[string]string
|
||||||
Accounts map[string]string
|
|
||||||
authPair struct {
|
type authPair struct {
|
||||||
Value string
|
Value string
|
||||||
User string
|
User string
|
||||||
}
|
}
|
||||||
authPairs []authPair
|
|
||||||
)
|
type authPairs []authPair
|
||||||
|
|
||||||
func (a authPairs) searchCredential(authValue string) (string, bool) {
|
func (a authPairs) searchCredential(authValue string) (string, bool) {
|
||||||
if len(authValue) == 0 {
|
if len(authValue) == 0 {
|
||||||
|
@ -23,15 +23,13 @@ const (
|
|||||||
ErrorTypeNu = 2
|
ErrorTypeNu = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type Error struct {
|
||||||
Error struct {
|
|
||||||
Err error
|
Err error
|
||||||
Type ErrorType
|
Type ErrorType
|
||||||
Meta interface{}
|
Meta interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
errorMsgs []*Error
|
type errorMsgs []*Error
|
||||||
)
|
|
||||||
|
|
||||||
var _ error = &Error{}
|
var _ error = &Error{}
|
||||||
|
|
||||||
|
11
fs.go
11
fs.go
@ -9,14 +9,13 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type onlyfilesFS struct {
|
||||||
onlyfilesFS struct {
|
|
||||||
fs http.FileSystem
|
fs http.FileSystem
|
||||||
}
|
}
|
||||||
neuteredReaddirFile struct {
|
|
||||||
|
type neuteredReaddirFile struct {
|
||||||
http.File
|
http.File
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally
|
// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used internally
|
||||||
// in router.Static().
|
// in router.Static().
|
||||||
|
17
gin.go
17
gin.go
@ -33,17 +33,17 @@ func (c HandlersChain) Last() HandlerFunc {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type (
|
type RouteInfo struct {
|
||||||
RoutesInfo []RouteInfo
|
|
||||||
RouteInfo struct {
|
|
||||||
Method string
|
Method string
|
||||||
Path string
|
Path string
|
||||||
Handler string
|
Handler string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Engine is the framework's instance, it contains the muxer, middleware and configuration settings.
|
type RoutesInfo []RouteInfo
|
||||||
// Create an instance of Engine, by using New() or Default()
|
|
||||||
Engine struct {
|
// 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
|
RouterGroup
|
||||||
delims render.Delims
|
delims render.Delims
|
||||||
HTMLRender render.HTMLRender
|
HTMLRender render.HTMLRender
|
||||||
@ -92,8 +92,7 @@ type (
|
|||||||
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
|
// If UseRawPath is false (by default), the UnescapePathValues effectively is true,
|
||||||
// as url.Path gonna be used, which is already unescaped.
|
// as url.Path gonna be used, which is already unescaped.
|
||||||
UnescapePathValues bool
|
UnescapePathValues bool
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
var _ IRouter = &Engine{}
|
var _ IRouter = &Engine{}
|
||||||
|
|
||||||
|
@ -16,8 +16,7 @@ const (
|
|||||||
defaultStatus = 200
|
defaultStatus = 200
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type ResponseWriter interface {
|
||||||
ResponseWriter interface {
|
|
||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
http.Hijacker
|
http.Hijacker
|
||||||
http.Flusher
|
http.Flusher
|
||||||
@ -38,14 +37,13 @@ type (
|
|||||||
|
|
||||||
// Forces to write the http header (status code + headers).
|
// Forces to write the http header (status code + headers).
|
||||||
WriteHeaderNow()
|
WriteHeaderNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
responseWriter struct {
|
type responseWriter struct {
|
||||||
http.ResponseWriter
|
http.ResponseWriter
|
||||||
size int
|
size int
|
||||||
status int
|
status int
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
var _ ResponseWriter = &responseWriter{}
|
var _ ResponseWriter = &responseWriter{}
|
||||||
|
|
||||||
|
@ -11,13 +11,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type IRouter interface {
|
||||||
IRouter interface {
|
|
||||||
IRoutes
|
IRoutes
|
||||||
Group(string, ...HandlerFunc) *RouterGroup
|
Group(string, ...HandlerFunc) *RouterGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
IRoutes interface {
|
type IRoutes interface {
|
||||||
Use(...HandlerFunc) IRoutes
|
Use(...HandlerFunc) IRoutes
|
||||||
|
|
||||||
Handle(string, string, ...HandlerFunc) IRoutes
|
Handle(string, string, ...HandlerFunc) IRoutes
|
||||||
@ -33,17 +32,16 @@ type (
|
|||||||
StaticFile(string, string) IRoutes
|
StaticFile(string, string) IRoutes
|
||||||
Static(string, string) IRoutes
|
Static(string, string) IRoutes
|
||||||
StaticFS(string, http.FileSystem) IRoutes
|
StaticFS(string, http.FileSystem) IRoutes
|
||||||
}
|
}
|
||||||
|
|
||||||
// RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix
|
// RouterGroup is used internally to configure router, a RouterGroup is associated with a prefix
|
||||||
// and an array of handlers (middleware)
|
// and an array of handlers (middleware)
|
||||||
RouterGroup struct {
|
type RouterGroup struct {
|
||||||
Handlers HandlersChain
|
Handlers HandlersChain
|
||||||
basePath string
|
basePath string
|
||||||
engine *Engine
|
engine *Engine
|
||||||
root bool
|
root bool
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
var _ IRouter = &RouterGroup{}
|
var _ IRouter = &RouterGroup{}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user