草庐IT

post-processing

全部标签

go - 使用 header 作为 application/json 在 Golang 中获取 POST 参数

我是golang的新手,正在尝试使用httprouter(https://github.com/julienschmidt/httprouter)通过POST方法创建RESTAPI。我使用简单的原始请求,header作为Content-Type:application/json。我已经很努力了,但没有找到获取原始查询参数的方法。req.FormValue("name")或req.Form.Get("name")工作正常,但标题为Content-Type:application/x-www-form-urlencoded有没有人试过获取原始查询参数(标题为Content-Type:app

go - 使用 POSTMAN 访问 FormValue Golang 中的 POST 请求值

我不知道为什么在POSTMAN中发送值时总是收到一个空字符串funcmain(){rtr:=mux.NewRouter()rtr.HandleFunc("/search",search).Methods("POST")}funcsearch(whttp.ResponseWriter,r*http.Request){name:=r.FormValue("name")//returnsempty}这是POSTMAN中的正文请求screenshotforthebodyrequest{"name":"markus"}我试图改变正文请求以形成数据Screenshotforformdatainpo

go - 发送带有请求正文的 POST 请求,就像字符串一样

我在我的网络服务器上设置了一个页面,其中包含一个“电子邮件地址”框和一个提交按钮。我有它,所以当它被提交时,它会发送一个发布请求来检查它是否存在于我的数据库中。我一直在使用Go来尝试发送这个POST请求。但是,我需要按以下方式发送请求正文:demo_mail=我还没有在网上找到任何有用的东西,只有一些帖子询问如何使用JSON而不是字符串发送数据。我目前有以下代码运行但无法发送带有上述发布数据的POST请求。req,err:=http.NewRequest("POST","",ioutil.NopCloser(bytes.NewBufferString("demo_mail="+emai

ajax - 无法从ajax请求中获取Golang中的post参数

在客户端我有代码:letresponse=awaitfetch('/getInfo',{credentials:'same-origin',method:'POST',body:JSON.stringify({filename:"file.jpg"})});服务端代码:fmt.Println(c.PostForm("filename"))//empty为什么是空的?如何获取c.PostForm("filename")的值? 最佳答案 此代码从请求正文中解码JSON对象://Requestisstructuretoencoderequ

json - 打印 POST JSON 数据

我在从POST打印JSON时遇到问题。我使用gorilla/mux进行路由r:=mux.NewRouter()r.HandleFunc("/test",Point).Methods("POST")http.ListenAndServe(":80",r)`在Point函数中我有funcPoint(whttp.ResponseWriter,r*http.Request){varcallbackDecoderjson.NewDecoder(r.Body).Decode(&callback)}但只有当我知道结构并且我想弄清楚如何将整个JSON作为字符串log.Print时,我才能使用此方法。我

go - standard_init_linux.go :207: exec user process caused "no such file or directory" while trying to statically link c libs

我无法在go中对用c编写的实用程序进行docker化和使用。我已经在没有docker的情况下在本地运行了这个程序并且它有效我尝试像这样使用gccgogobuild-compilergccgo-gccgoflags-static-libgo但我得到了同样的错误调用C函数的序言如下所示:/*#cgoamd64x86LDFLAGS:-L.-lsomelib-lsomeotherlib#include#include#include"someheader.h"*/我的docker文件如下所示:FROMgolang:1.12ASbuildWORKDIR/go/src/appCOPY..ENVGO

docker - 从 Ubuntu amd64 到 arm7l : exec user process caused "exec format error" 进行交叉编译

从amd64到arm7l的交叉编译让我头疼我终于可以用GitlabCI做到这一点,所以现在,我在docker镜像中编译我的二进制文件,这是dockerfile:FROMgolangWORKDIR/go/src/gitlab.com/company/edge_to_bcCOPY..RUNdpkg--add-architecturearmhf&&aptupdate&&apt-getinstall-ygcc-arm-linux-gnueabihflibltdl-dev:armhf我将其构建为然后我将使用名称ubuntu:cross-compil构建新容器“cross-compil”现在,我可

go - 无法在 http 请求中设置 POST 正文

这不是设置POST请求正文的正确方法吗?data:=url.Values{}data.Set("url","https://www.google.com/")client:=http.Client{}r,err:=http.NewRequest(http.MethodPost,apiURL,strings.NewReader(data.Encode()))下面的代码在执行时表明POST请求中没有发送urlparam。packagemainimport("fmt""io/ioutil""net/http""net/url""strings")funcdoAPICall(){//curl-

go - 获取 Go 的 HTTP post 来模拟 curl -d

我正在尝试通过Go将内容发布到nginx服务器。我已验证我能够通过curl正确发布此内容,特别是使用此命令:$curlhttp://example.com/myendpoint-d"SomeText"我能够看到这个POST,并正确处理它。但是,当我尝试使用Go执行POST时,它被服务器拒绝了。在nginx访问日志中,我看到这两行:127.0.0.1--[30/Jan/2014:05:57:34+0000]"POST/myendpointHTTP/1.1"4000"-""Go1.1packagehttp"127.0.0.1--[30/Jan/2014:05:57:39+0000]"Som

image-processing - Golang 中的卷积

我想在图像上执行卷积乘积。原图为:所以我用gimp测试卷积。使用此矩阵:111111111和分隔线9我得到当我执行我的算法时,我得到:我的算法是:funcConvolution(img*image.Image,matrice[][]int)*image.NRGBA{imageRGBA:=image.NewNRGBA((*img).Bounds())w:=(*img).Bounds().Dx()h:=(*img).Bounds().Dy()sumR:=0sumB:=0sumG:=0varruint32varguint32varbuint32fory:=0;y错误在哪里?谢谢您的帮助。