Skip to content

Param returning empty string #9

@tekknolagi

Description

@tekknolagi

I modified the example project a bit, adding this:

func nextUserId() string {
    var next = nextid;
    nextid += 1;
    return strconv.Itoa(next)
}

func createUser(c *echo.Context) {
    u := new(user)
    u.ID = nextUserId()
    u.Name = c.Param("name")

    if c.Bind(u) {
        users[u.ID] = *u
        c.JSON(http.StatusCreated, u)
    }
}

Except u.Name is for some reason always the empty string. What am I doing wrong? I've looked at the context.go source and it looks like it should work.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions