httpserver实现简单的上下文

package main

import (
    "net/http"

    "com.jtthink.net/myhttpserver/core"
)

type MyHandler struct {

}
func(*MyHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request){

     writer.Write([]byte("hello,myhandler"))
}

func main()  {

     router:=core.DefaultRouter()

    router.Get("/", func(ctx *core.MyContext) {
        ctx.WriteString("my string GET")
    })
    router.Post("/", func(ctx *core.MyContext) {
        ctx.WriteString("my string POST")
    })

    http.ListenAndServe(":8099",router)





}
main.go

相关文章:

  • 2021-08-10
  • 2021-11-21
  • 2021-06-13
  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-12-25
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-05
  • 2021-09-05
相关资源
相似解决方案