binding

package
v0.0.0-...-916c69f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

*FileHeader

  • @Author: Liangkang Zhang
  • @Date: 2026/1/26 23:42:17
  • @LastEditors: Liangkang Zhang
  • @LastEditTime: 2026/1/26 23:42:25
  • @Description:
  • @Copyright: Copyright (©)}) 2026 Liangkang Zhang<lkzhang98@gmail.com>. All rights reserved. Use of this source code is governed by a MIT style license that can be found in the LICENSE file.. All rights reserved.
  • @Email: lkzhang98@gmail.com
  • @Repository: https://github.com/geminik12/autostack

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(c *gin.Context, obj interface{}, bindFuncs ...func(*gin.Context, interface{}) error) error

Bind processes data from multiple sources without validating between each step, then performs a single validation at the end.

This solves the problem where binding from one source (e.g., URI) fails validation because fields from another source (e.g., JSON) haven't been bound yet.

Example usage:

var req UserUpdateRequest
if err := binding.Bind(c, &req, binding.URI, binding.JSON); err != nil {
    c.JSON(http.StatusBadRequest, ErrorResponse{Message: err.Error()})
    return
}

func JSON

func JSON(c *gin.Context, obj interface{}) error

JSON binds JSON body to the given object. Uses Gin's ShouldBindJSON but without validation.

func URI

func URI(c *gin.Context, obj interface{}) error

URI binds URI parameters to the given object. Uses Gin's ShouldBindUri but without validation.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL