> For the complete documentation index, see [llms.txt](https://easonwang.gitbook.io/golang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://easonwang.gitbook.io/golang/di-san-fang-mo-zu/iriskuang-jia/du-qu-body-zi-liao.md).

# 讀取 Body 資料

### Raw JSON

```go
		app.Post("/", func(ctx iris.Context) {
		  rawBodyAsBytes, err := ioutil.ReadAll(ctx.Request().Body)
		  if err != nil { /* handle the error */
		  	ctx.Writef("%v", err)
		  }
		  rawBodyAsString := string(rawBodyAsBytes)
		  ctx.JSON(rawBodyAsString)
		}
```

### x-www-form-urlencode

```go
app.Post("/", func(ctx iris.Context) {
		username := ctx.PostValue("age")
		fmt.Println(username)
		ctx.Writef(username)
}
```

### form-data

```go
app.Post("/", func(ctx iris.Context) {		
		type Visitor struct {
			Name string `form:"name"`
		}
		visitor := Visitor{}
		err := ctx.ReadForm(&visitor)
		if err != nil {
			ctx.StatusCode(iris.StatusInternalServerError)
			ctx.WriteString(err.Error())
		}
		ctx.Writef("%s", visitor)
}
```
