Using GET, POST, PUT, PATCH, DELETE and OPTIONS

  1. func main() {
  2. // Disable Console Color
  3. // gin.DisableConsoleColor()
  4. // Creates a gin router with default middleware:
  5. // logger and recovery (crash-free) middleware
  6. router := gin.Default()
  7. router.GET("/someGet", getting)
  8. router.POST("/somePost", posting)
  9. router.PUT("/somePut", putting)
  10. router.DELETE("/someDelete", deleting)
  11. router.PATCH("/somePatch", patching)
  12. router.HEAD("/someHead", head)
  13. router.OPTIONS("/someOptions", options)
  14. // By default it serves on :8080 unless a
  15. // PORT environment variable was defined.
  16. router.Run()
  17. // router.Run(":3000") for a hard coded port
  18. }