Home  >  Article  >  Backend Development  >  How to read post string in go via gin-gonic

How to read post string in go via gin-gonic

PHPz
PHPzforward
2024-02-09 21:27:21822browse

如何通过 gin-gonic 读取 go 中的帖子字符串

In Go language, reading post string using gin-gonic framework is a common task. With gin-gonic we can easily handle HTTP requests and responses and extract the required data from them. This article will show you how to read post strings in Go using the gin-gonic framework. Let us follow the guidance of PHP editor Yuzai and explore this interesting and practical technique together!

Question content

This may be a stupid question, but I just can't get this from the documentation. please help

So, I want the client to send a POST request like this

curl -X POST localhost -d "haha"

This is not json or any encoding, but a simple string How do I read this via gin-gonic?

Thank you

Solution

This solves the problem

str, err := c.GetRawData()

The above is the detailed content of How to read post string in go via gin-gonic. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:stackoverflow.com. If there is any infringement, please contact admin@php.cn delete