httpbin.go 493 B

123456789101112131415161718192021222324252627
  1. package main
  2. import (
  3. "github.com/gin-gonic/gin"
  4. "net/http"
  5. "runtime"
  6. )
  7. func main() {
  8. runtime.GOMAXPROCS(-1)
  9. router := gin.New()
  10. router.POST("", reply)
  11. router.GET("", reply)
  12. _ = router.Run(":9090")
  13. }
  14. func reply(ctxt *gin.Context) {
  15. println("url", ctxt.Request.URL.String())
  16. sign := ctxt.GetHeader("X-Gogs-Signature")
  17. println("X-Gogs-Signature", sign)
  18. buf := make([]byte, 10240)
  19. n, _ := ctxt.Request.Body.Read(buf)
  20. println(string(buf[0:n]))
  21. ctxt.JSON(http.StatusOK, "OK")
  22. }