github.com/wangyougui/gf/v2@v2.6.5/frame/g/g_z_example_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package g_test
     8  
     9  import (
    10  	"github.com/wangyougui/gf/v2/frame/g"
    11  	"github.com/wangyougui/gf/v2/net/ghttp"
    12  )
    13  
    14  func ExampleServer() {
    15  	// A hello world example.
    16  	s := g.Server()
    17  	s.BindHandler("/", func(r *ghttp.Request) {
    18  		r.Response.Write("hello world")
    19  	})
    20  	s.SetPort(8999)
    21  	s.Run()
    22  }