# 一次完整的請求數據請求處理過程
>[info] 1、新建一個文件 `input.go`,添加包名(命名空間)
~~~
package controllers
~~~
>[info] 2、定義一個類(struct)
~~~
type InputController struct {
BaseController
}
~~~
>[info] 3、給類寫方法(fun)
~~~
func (this *InputController) InputGet(){
id := this.GetString("id")
this.Ctx.WriteString("id value = "+id)
}
~~~
>[info] 4、給類(struct)的方法(Fun)寫路由(router)
~~~
beego.Router("/input_get",&controllers.InputController{},"*:InputGet")
~~~
>[info] 5、完整代碼
~~~
package controllers
// 定義類
type InputController struct {
BaseController
}
// 類方法
func (this *InputController) InputGet(){
name := this.GetString("name")
// 不使用模版,直接用 this.Ctx.WriteString 輸出字符串
this.Ctx.WriteString(name)
}
~~~
>[info] 6、重新編譯(bee run),瀏覽器或者Postman通過Get方式訪問
~~~
http://127.0.0.1:8080/input_get?name=Tinywan
//打印結果
Tinywan
~~~