Merge cd9cecb392cb3ba80344b5692535ed5de4693702 into 5f4f9643258dc2a65e684b63f12c8d543c936c67

This commit is contained in:
Sediman AI 2026-05-28 20:34:41 +08:00 committed by GitHub
commit f09d0a4fbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -100,6 +100,8 @@ func (group *RouterGroup) handle(httpMethod, relativePath string, handlers Handl
// This function is intended for bulk loading and to allow the usage of less
// frequently used, non-standardized or custom methods (e.g. for internal
// communication with a proxy).
//
// Handle panics if httpMethod is not a valid, uppercase ASCII HTTP method name.
func (group *RouterGroup) Handle(httpMethod, relativePath string, handlers ...HandlerFunc) IRoutes {
if matched := regEnLetter.MatchString(httpMethod); !matched {
panic("http method " + httpMethod + " is not valid")
@ -200,6 +202,8 @@ func (group *RouterGroup) Static(relativePath, root string) IRoutes {
// StaticFS works just like `Static()` but a custom `http.FileSystem` can be used instead.
// Gin by default uses: gin.Dir()
//
// StaticFS panics if relativePath contains URL parameters (:param or *wildcard).
func (group *RouterGroup) StaticFS(relativePath string, fs http.FileSystem) IRoutes {
if strings.Contains(relativePath, ":") || strings.Contains(relativePath, "*") {
panic("URL parameters can not be used when serving a static folder")

View File

@ -26,6 +26,7 @@ const localhostIP = "127.0.0.1"
const localhostIPv6 = "::1"
// Bind is a helper function for given interface object and returns a Gin middleware.
// Bind panics if val is a pointer; pass the struct value directly (e.g. Bind(MyStruct{}) not Bind(&MyStruct{})).
func Bind(val any) HandlerFunc {
value := reflect.ValueOf(val)
if value.Kind() == reflect.Ptr {