Colleen Larsen
Colleen Larsen

Reputation: 733

How to parse html forms in the Go Iris framework?

Sorry if this question is a bit basic, but how can you parse form inputs in the Go Iris framework? Here is the form I am using

<form action="/" method="post">
    Username:<input type="text" name="username">
    Password:<input type="password" name="password">
    <input type="submit" value="Login">
</form>

here is the route and the controller respectively

iris.Post("/", TestController)
func TestController(c *iris.Context){

    username := c.Form.Get("username")//Doesn't work
    password := c.Form.Get("password")//Doesn't work

}

how do I retrieve the values in the Post request after the form has been submitted, Thanks

Upvotes: 2

Views: 1037

Answers (1)

evanmcdonnal
evanmcdonnal

Reputation: 48114

Based off an example on the iris github page you could try c.PostValue("Username"). The code you have may also work but I think you need to capitalize the variable names. In the html template you can see the name value is lowercased, however your context is more likely going off those the variable names to the left of the actual html like Username.

Upvotes: 3

Related Questions