This is a creation in Article, where the information may have evolved or changed.
Package Controllersimport (."Logger" "Web")//object inherits directly with rest standard interface type login struct {web. Controllerbase}func (This *login) Get () {This. Template["Key"] ="Value"This. WriteString("GET:", this. Template)}func (this *login) Post () {This. WriteString("POST:", this. TemplateThe}//object does not inherit the registration of a method to the route type signout struct {}func (this *signout) signoutget (CTX *web. HttpContext) {CTX. WriteString("Signoutget:", CTX. Template)}func (this *signout) signoutpost (CTX *web. HttpContext) {CTX. WriteString("Signoutpost:", CTX. Template) The}//function directly registers the routing func indexget (ctx *web. HttpContext) {CTX. WriteString("Index Get:", CTX. Template)}func Indexpost (CTX *web. HttpContext) {CTX. WriteString("Index Post:", CTX. Template)}func Printget (CTX *web. HttpContext) {CTX. WriteString(web. Printroute("%v<br>")///Print Data Routing status}//action level interceptor contains get POST put.....func indexactionfilter (ctx *web. HttpContext) {CTX. WriteString("Indexactionfilter:", CTX. Template) CTX. Next()//down pass the registered route}func Globalfilter (CTX *web. HttpContext) {CTX. WriteString("Globalfilter:") Switch CTX. Params["Next"] {case"Yes": CTX. Next()}}func init () {Web. Bringinlog(Logger)//push into a third-party middleware switch//function direct registration route ... Web. Registerroute("/index", Indexget) Web. Registerroute("/index", Indexpost) Web. Registerroute("/print", Printget)//object anonymous inheritance direct with rest standard interface web. Registerroute("/login", &login{})//object does not inherit to register a method to the routing web. Registerroute("/signout", (&signout{}). Signoutget)//Register an action-level interceptor Web. Registeractionfilter("/index", indexactionfilter)//global-level interceptor web. Registerglobalfilter(Globalfilter)}