✨ added POST-endpoint for userform
Co-authored-by: haraldnilsen <harald_998@hotmail.com> Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
parent
b78003b4fc
commit
dd8f22b043
7 changed files with 74 additions and 18 deletions
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -16,6 +18,15 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
// Info about user
|
||||
router.POST("/submitform", func(c *gin.Context) {
|
||||
jsonData, err := io.ReadAll(c.Request.Body)
|
||||
if err != nil {
|
||||
// Handle error
|
||||
}
|
||||
fmt.Print(string(jsonData))
|
||||
})
|
||||
|
||||
// Run the server on port 8080
|
||||
router.Run(":8080")
|
||||
}
|
||||
|
|
Reference in a new issue