Compare commits
1 Commits
master
...
116d0b112e
Author | SHA1 | Date | |
---|---|---|---|
116d0b112e |
8
araneae_context.go
Normal file
8
araneae_context.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package gin
|
||||||
|
|
||||||
|
import "golang.org/x/net/context"
|
||||||
|
|
||||||
|
// BaseContext gets the basic context of the request
|
||||||
|
func (ctx *Context) BaseContext() context.Context {
|
||||||
|
return ctx.Request.Context()
|
||||||
|
}
|
310
araneae_request.go
Normal file
310
araneae_request.go
Normal file
@ -0,0 +1,310 @@
|
|||||||
|
package gin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"mime/multipart"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IRequest interface {
|
||||||
|
// url query
|
||||||
|
// e.g. foo.com?a=1&b=bar&c[]=bar
|
||||||
|
QueryAll(key string) url.Values
|
||||||
|
QueryIntWithDefault(key string, defval int) (int, bool)
|
||||||
|
QueryInt64WithDefault(key string, defval int64) (int64, bool)
|
||||||
|
QueryFloat32WithDefault(key string, defval float32) (float32, bool)
|
||||||
|
QueryFloat64WithDefault(key string, defval float64) (float64, bool)
|
||||||
|
QueryBoolWithDefault(key string, defval bool) (bool, bool)
|
||||||
|
QueryStringWithDefault(key string, defval string) (string, bool)
|
||||||
|
QueryStringSliceWithDefault(key string, defval []string) ([]string, bool)
|
||||||
|
|
||||||
|
// url params
|
||||||
|
// e.g. /book/:id
|
||||||
|
Param(key string) string
|
||||||
|
ParamIntWithDefault(key string, defval int) (int, bool)
|
||||||
|
ParamInt64WithDefault(key string, defval int64) (int64, bool)
|
||||||
|
ParamFloat32WithDefault(key string, defval float32) (float32, bool)
|
||||||
|
ParamFloat64WithDefault(key string, defval float64) (float64, bool)
|
||||||
|
ParamBoolWithDefault(key string, defval bool) (bool, bool)
|
||||||
|
ParamStringWithDefault(key string, defval string) (string, bool)
|
||||||
|
|
||||||
|
// form
|
||||||
|
FormAllWithDefault(key string) url.Values
|
||||||
|
FormIntWithDefault(key string, defval int) (int, bool)
|
||||||
|
FormInt64WithDefault(key string, defval int64) (int64, bool)
|
||||||
|
FormFloat32WithDefault(key string, defval float32) (float32, bool)
|
||||||
|
FormFloat64WithDefault(key string, defval float64) (float64, bool)
|
||||||
|
FormBoolWithDefault(key string, defval bool) (bool, bool)
|
||||||
|
FormStringWithDefault(key string, defval string) (string, bool)
|
||||||
|
FormStringSliceWithDefault(key string, defval []string) ([]string, bool)
|
||||||
|
FormFile(key string) (*multipart.FileHeader, error)
|
||||||
|
|
||||||
|
// JSON body
|
||||||
|
BindJSON(obj any) error
|
||||||
|
|
||||||
|
// XML body
|
||||||
|
BindXML(obj any) error
|
||||||
|
|
||||||
|
// RAW body
|
||||||
|
GetRawData() ([]byte, error)
|
||||||
|
|
||||||
|
// Basic informations
|
||||||
|
Uri() string
|
||||||
|
Method() string
|
||||||
|
Host() string
|
||||||
|
ClientIP() string
|
||||||
|
|
||||||
|
// Header
|
||||||
|
Headers() map[string][]string
|
||||||
|
Header(key string) (string, bool)
|
||||||
|
|
||||||
|
// Cookie
|
||||||
|
Cookies() map[string]string
|
||||||
|
Cookie(key string) (string, bool)
|
||||||
|
}
|
||||||
|
|
||||||
|
// {{{ url query
|
||||||
|
|
||||||
|
// QueryAll returns all queries in a request URL
|
||||||
|
func (ctx *Context) QueryAll() url.Values {
|
||||||
|
if ctx.Request != nil {
|
||||||
|
return map[string][]string(ctx.Request.URL.Query())
|
||||||
|
}
|
||||||
|
return url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryInt gets an int value from the query request
|
||||||
|
func (ctx *Context) QueryIntWithDefault(key string, defval int) (int, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToInt(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) QueryInt64WithDefault(key string, defval int64) (int64, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToInt64(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) QueryBoolWithDefault(key string, defval bool) (bool, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToBool(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) QueryFloat32WithDefault(key string, defval float32) (float32, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToFloat32(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) QueryFloat64WithDefault(key string, defval float64) (float64, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToFloat64(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryString gets a string value from the query request
|
||||||
|
func (ctx *Context) QueryStringWithDefault(key string, defval string) (string, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToString(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// QueryArray gets an array of string values from the query request
|
||||||
|
func (ctx *Context) QueryStringSliceWithDefault(key string, defval []string) ([]string, bool) {
|
||||||
|
params := ctx.QueryAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
return cast.ToStringSlice(vals[0]), true
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ url params
|
||||||
|
|
||||||
|
func (ctx *Context) ParamIntWithDefault(key string, def int) (int, bool) {
|
||||||
|
if val := ctx.Param(key); val != "" {
|
||||||
|
return cast.ToInt(val), true
|
||||||
|
}
|
||||||
|
return def, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ParamInt64WithDefault(key string, def int64) (int64, bool) {
|
||||||
|
if val := ctx.Param(key); val != "" {
|
||||||
|
return cast.ToInt64(val), true
|
||||||
|
}
|
||||||
|
return def, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ParamFloat64WithDefault(key string, def float64) (float64, bool) {
|
||||||
|
if val := ctx.Param(key); val != "" {
|
||||||
|
return cast.ToFloat64(val), true
|
||||||
|
}
|
||||||
|
return def, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ParamFloat32WithDefault(key string, def float32) (float32, bool) {
|
||||||
|
if val := ctx.Param(key); val != "" {
|
||||||
|
return cast.ToFloat32(val), true
|
||||||
|
}
|
||||||
|
return def, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ParamBoolWithDefault(key string, def bool) (bool, bool) {
|
||||||
|
if val := ctx.Param(key); val != "" {
|
||||||
|
return cast.ToBool(val), true
|
||||||
|
}
|
||||||
|
return def, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ParamStringWithDefault(key string, def string) (string, bool) {
|
||||||
|
if val := ctx.Param(key); val != "" {
|
||||||
|
return cast.ToString(val), true
|
||||||
|
}
|
||||||
|
return def, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ Post form
|
||||||
|
|
||||||
|
// FormAll gets everything from the submitted form
|
||||||
|
func (ctx *Context) FormAll() url.Values {
|
||||||
|
if ctx.Request != nil {
|
||||||
|
_ = ctx.Request.ParseForm()
|
||||||
|
return ctx.Request.PostForm
|
||||||
|
}
|
||||||
|
return url.Values{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormInt gets an int value from the submitted form
|
||||||
|
func (ctx *Context) FormIntWithDefault(key string, defval int) (int, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToInt(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) FormInt64WithDefault(key string, defval int64) (int64, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToInt64(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) FormBoolWithDefault(key string, defval bool) (bool, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToBool(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) FormFloat32WithDefault(key string, defval float32) (float32, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToFloat32(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) FormFloat64WithDefault(key string, defval float64) (float64, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToFloat64(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) FormStringWithDefault(key string, defval string) (string, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
if len(vals) > 0 {
|
||||||
|
return cast.ToString(vals[0]), true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) FormStringSliceWithDefault(key string, defval []string) ([]string, bool) {
|
||||||
|
params := ctx.FormAll()
|
||||||
|
if vals, ok := params[key]; ok {
|
||||||
|
return cast.ToStringSlice(vals[0]), true
|
||||||
|
}
|
||||||
|
return defval, false
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ Basic informations
|
||||||
|
|
||||||
|
func (ctx *Context) Uri() string {
|
||||||
|
return ctx.Request.RequestURI
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) Method() string {
|
||||||
|
return ctx.Request.Method
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) Host() string {
|
||||||
|
return ctx.Request.Host
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ Headers
|
||||||
|
|
||||||
|
// Header
|
||||||
|
func (ctx *Context) Headers() map[string][]string {
|
||||||
|
return ctx.Request.Header
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
||||||
|
// {{{ Cookies
|
||||||
|
|
||||||
|
// Cookies gets cookie key-value pairs
|
||||||
|
func (ctx *Context) Cookies() map[string]string {
|
||||||
|
cookies := ctx.Request.Cookies()
|
||||||
|
ret := map[string]string{}
|
||||||
|
for _, c := range cookies {
|
||||||
|
ret[c.Name] = c.Value
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// }}}
|
78
araneae_response.go
Normal file
78
araneae_response.go
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
package gin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IResponse interface {
|
||||||
|
IJSON(status int, obj any) IResponse
|
||||||
|
IXML(status int, obj any) IResponse
|
||||||
|
IHTML(status int, filepath string, obj any) IResponse
|
||||||
|
IText(status int, format string, values ...any) IResponse
|
||||||
|
|
||||||
|
IRedirect(status int, path string) IResponse
|
||||||
|
ISetHeader(key string, val string) IResponse
|
||||||
|
ISetCookie(
|
||||||
|
key string,
|
||||||
|
val string,
|
||||||
|
maxAge int,
|
||||||
|
path, domain string,
|
||||||
|
secure, httpOnly bool,
|
||||||
|
) IResponse
|
||||||
|
ISetStatus(code int) IResponse
|
||||||
|
|
||||||
|
// set 200
|
||||||
|
ISetOKStatus() IResponse
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) IJSON(status int, obj any) IResponse {
|
||||||
|
ctx.JSON(status, obj)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) IXML(status int, obj any) IResponse {
|
||||||
|
ctx.XML(status, obj)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) IHTML(status int, filepath string, obj any) IResponse {
|
||||||
|
ctx.HTML(status, filepath, obj)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) IText(status int, format string, values ...any) IResponse {
|
||||||
|
ctx.String(status, format, values...)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) IRedirect(status int, path string) IResponse {
|
||||||
|
ctx.Redirect(status, path)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ISetHeader(key string, val string) IResponse {
|
||||||
|
ctx.Header(key, val)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ISetCookie(
|
||||||
|
key string,
|
||||||
|
val string,
|
||||||
|
maxAge int,
|
||||||
|
path, domain string,
|
||||||
|
secure, httpOnly bool,
|
||||||
|
) IResponse {
|
||||||
|
ctx.SetCookie(key, val, maxAge, path, domain, secure, httpOnly)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ctx *Context) ISetStatus(code int) IResponse {
|
||||||
|
ctx.Status(code)
|
||||||
|
return ctx
|
||||||
|
}
|
||||||
|
|
||||||
|
// set 200
|
||||||
|
func (ctx *Context) ISetOKStatus() IResponse {
|
||||||
|
ctx.Status(http.StatusOK)
|
||||||
|
return ctx
|
||||||
|
}
|
@ -19,7 +19,6 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"git.vinchent.xyz/vinchent/go-web/framework"
|
|
||||||
"github.com/gin-contrib/sse"
|
"github.com/gin-contrib/sse"
|
||||||
"github.com/gin-gonic/gin/binding"
|
"github.com/gin-gonic/gin/binding"
|
||||||
"github.com/gin-gonic/gin/render"
|
"github.com/gin-gonic/gin/render"
|
||||||
@ -90,9 +89,6 @@ type Context struct {
|
|||||||
// SameSite allows a server to define a cookie attribute making it impossible for
|
// SameSite allows a server to define a cookie attribute making it impossible for
|
||||||
// the browser to send this cookie along with cross-site requests.
|
// the browser to send this cookie along with cross-site requests.
|
||||||
sameSite http.SameSite
|
sameSite http.SameSite
|
||||||
|
|
||||||
// GoWeb service container
|
|
||||||
container framework.Container
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************/
|
/************************************/
|
||||||
|
4
gin.go
4
gin.go
@ -15,7 +15,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.vinchent.xyz/vinchent/go-web/framework"
|
|
||||||
"github.com/gin-gonic/gin/internal/bytesconv"
|
"github.com/gin-gonic/gin/internal/bytesconv"
|
||||||
"github.com/gin-gonic/gin/render"
|
"github.com/gin-gonic/gin/render"
|
||||||
|
|
||||||
@ -179,9 +178,6 @@ type Engine struct {
|
|||||||
maxSections uint16
|
maxSections uint16
|
||||||
trustedProxies []string
|
trustedProxies []string
|
||||||
trustedCIDRs []*net.IPNet
|
trustedCIDRs []*net.IPNet
|
||||||
|
|
||||||
// GoWeb service container
|
|
||||||
container framework.Container
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var _ IRouter = (*Engine)(nil)
|
var _ IRouter = (*Engine)(nil)
|
||||||
|
16
go.mod
16
go.mod
@ -1,11 +1,8 @@
|
|||||||
module github.com/gin-gonic/gin
|
module github.com/gin-gonic/gin
|
||||||
|
|
||||||
go 1.22.5
|
go 1.21.0
|
||||||
|
|
||||||
toolchain go1.23.1
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
git.vinchent.xyz/vinchent/go-web v0.0.0-20240929215000-f0fc7ee2cb65
|
|
||||||
github.com/bytedance/sonic v1.11.6
|
github.com/bytedance/sonic v1.11.6
|
||||||
github.com/gin-contrib/sse v0.1.0
|
github.com/gin-contrib/sse v0.1.0
|
||||||
github.com/go-playground/validator/v10 v10.20.0
|
github.com/go-playground/validator/v10 v10.20.0
|
||||||
@ -14,6 +11,7 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.20
|
github.com/mattn/go-isatty v0.0.20
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2
|
github.com/pelletier/go-toml/v2 v2.2.2
|
||||||
github.com/quic-go/quic-go v0.43.1
|
github.com/quic-go/quic-go v0.43.1
|
||||||
|
github.com/spf13/cast v1.7.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
github.com/ugorji/go/codec v1.2.12
|
github.com/ugorji/go/codec v1.2.12
|
||||||
golang.org/x/net v0.27.0
|
golang.org/x/net v0.27.0
|
||||||
@ -31,18 +29,16 @@ require (
|
|||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
|
||||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/leodido/go-urn v1.4.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
github.com/onsi/ginkgo/v2 v2.9.5 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/quic-go/qpack v0.4.0 // indirect
|
github.com/quic-go/qpack v0.4.0 // indirect
|
||||||
github.com/rogpeppe/go-internal v1.9.0 // indirect
|
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
go.uber.org/mock v0.4.0 // indirect
|
go.uber.org/mock v0.4.0 // indirect
|
||||||
golang.org/x/arch v0.8.0 // indirect
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
|
||||||
golang.org/x/crypto v0.25.0 // indirect
|
golang.org/x/crypto v0.25.0 // indirect
|
||||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
|
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db // indirect
|
||||||
golang.org/x/mod v0.17.0 // indirect
|
golang.org/x/mod v0.17.0 // indirect
|
||||||
@ -50,5 +46,3 @@ require (
|
|||||||
golang.org/x/text v0.16.0 // indirect
|
golang.org/x/text v0.16.0 // indirect
|
||||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
replace git.vinchent.xyz/vinchent/go-web/ => ./../../
|
|
||||||
|
17
go.sum
17
go.sum
@ -1,5 +1,3 @@
|
|||||||
git.vinchent.xyz/vinchent/go-web v0.0.0-20240929215000-f0fc7ee2cb65 h1:7sHTzY0WpgX4UW2g+dp+icvRyfcreP1fknOJ7/EDvtY=
|
|
||||||
git.vinchent.xyz/vinchent/go-web v0.0.0-20240929215000-f0fc7ee2cb65/go.mod h1:0t1NertSVVZD1FU7F6RkLb1Y5lcLU96pWygIOIeYjTI=
|
|
||||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
||||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
||||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
||||||
@ -11,10 +9,11 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/
|
|||||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
||||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
||||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
|
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
@ -43,9 +42,8 @@ github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLe
|
|||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
|
github.com/klauspost/cpuid/v2 v2.0.9 h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
|
||||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
||||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
@ -55,9 +53,8 @@ github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
|||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
|
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
|
||||||
@ -74,6 +71,8 @@ github.com/quic-go/quic-go v0.43.1 h1:fLiMNfQVe9q2JvSsiXo4fXOEguXHGGl9+6gLp4RPeZ
|
|||||||
github.com/quic-go/quic-go v0.43.1/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
|
github.com/quic-go/quic-go v0.43.1/go.mod h1:132kz4kL3F9vxhW3CtQJLDVwcFe5wdWeJXXijhsO57M=
|
||||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||||
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
|
||||||
|
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
|
||||||
|
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@ -93,9 +92,8 @@ github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65E
|
|||||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||||
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
|
||||||
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
|
||||||
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 h1:18EFjUmQOcUvxNYSkA6jO9VAiXCnxFY6NyDX0bHDmkU=
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
|
||||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
|
||||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||||
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
|
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db h1:D/cFflL63o2KSLJIwjlcIt8PR064j/xsmdEJL/YvY/o=
|
||||||
@ -107,7 +105,6 @@ golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
|||||||
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
|
||||||
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
@ -1,27 +0,0 @@
|
|||||||
package gin
|
|
||||||
|
|
||||||
import "git.vinchent.xyz/vinchent/go-web/framework"
|
|
||||||
|
|
||||||
// Engine handles the bind process
|
|
||||||
|
|
||||||
func (engine *Engine) Bind(provider framework.ServiceProvider) error {
|
|
||||||
return engine.container.Bind(provider)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (engine *Engine) IsBound(key string) bool {
|
|
||||||
return engine.container.IsBound(key)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Context handle the use process.
|
|
||||||
|
|
||||||
func (ctx *Context) Make(name string) (interface{}, error) {
|
|
||||||
return ctx.container.Make(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ctx *Context) MustMake(name string) interface{} {
|
|
||||||
return ctx.container.MustMake(name)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ctx *Context) MakeNew(name string, params []interface{}) (interface{}, error) {
|
|
||||||
return ctx.container.MakeNew(name, params)
|
|
||||||
}
|
|
Reference in New Issue
Block a user