Coder Social home page Coder Social logo

gin-api-template's People

Contributors

fxiang21 avatar ivongwy avatar pycook avatar rickywei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gin-api-template's Issues

[Bug]: package main is not in std

Contact Details

No response

This bug is related to UI or API?

No response

What happened?

A bug happened!

Version

newest

What browsers are you seeing the problem on?

No response

Relevant log output

No response

[help wanted]: 使用 postman 发送 post 请求,使用 raw 源的 json 数据,无法绑定到结构体

Contact Details

No response

What is your question?

我使用postman 发送 post 请求,数据源是 raw, json 结构。 但是无论怎样,都无法使用 gin 的 ShouldBind 以及 ShouldBindJson 获取到发送的数据,下面是我的代码:

package controller

type SmsParams struct {
	UserMobile string `json:"userMobile" form:"userMobile" uri:"userMobile" xml:"userMobile" binding:"required"`
}
func (c *Controller) SmsController(ctx *gin.Context) {
	var respMap = make(map[string]interface{})

	// 解析参数
	raw := &SmsParams{}
	bindErr := ctx.ShouldBind(raw)
	if bindErr != nil {
		FailureResponse(ctx, bindErr.Error())
		return
	}

	fmt.Println("smsParams-->", raw)
	SuccessResponse(ctx)
}

下面是 postman 设置:
image

下面是输出日志:

image

请问有哪里需要调整?

Version

newest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.