Post Reqeust via HTML FORM GinGonic golang framework 11

Post Reqeust via HTML FORM GinGonic golang framework 11



Source Code

[sourcecode lang=”go” autolinks=”false” classname=”myclass” collapse=”false” firstline=”1″ gutter=”true” highlight=”1-3,6,9″ htmlscript=”false” light=”false” padlinenumbers=”false” smarttabs=”true” tabsize=”4″ toolbar=”false” title=”Source Code main.go”]

// POST Request via HTML Form
package main
import ""
func main() {
// create new router/server
r := gin.Default()
// register root folder for HTML Form file
r.Static("/", "./")
// post request
r.POST("/post", func(c *gin.Context) {
name := c.PostForm("name") // is the name of field
// send back data received or show success
c.String(200, "Hi %s", name)
// lets create html form

Source Code – Index.html


<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HTML POST REQ FORM</title>
<form action="/post" method="post">
<input type="text" name="name" id="">
<button type="submit">submit</button>




gin gonic tutorial
gin-gonic / examples
gin-gonic documentation
gin framework tutorial
gin web framework
gin router
golang gin context
gin router group

Tony BB

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: