Skip to content

Releases: rozdolsky33/toolkit

Version v2.0.0 Release Notes

28 Sep 15:15
Compare
Choose a tag to compare

v2.0.0 Release Notes

New Features

  • DownloadStaticFile Function

    • Added a new method DownloadStaticFile to the Tools struct for downloading files. This method sets the Content-Disposition header to "attachment" to force file download rather than display in the browser. Additionally, it allows for a specified display name.
      func (t *Tools) DownloadStaticFile(w http.ResponseWriter, r *http.Request, pathName, displayName string) {
          w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", displayName))
          http.ServeFile(w, r, pathName)
      }
  • JSONResponse Struct

    • Introduced the JSONResponse struct for a standardized format of JSON responses. It includes fields for:
      • Error (a boolean indicating if there is an error)
      • Message (a string for the message)
      • Data (an optional field for additional data)
      type JSONResponse struct {
          Error   bool        `json:"error"`
          Message string      `json:"message"`
          Data    interface{} `json:"data,omitempty"`
      }

Initial release

28 Sep 15:00
Compare
Choose a tag to compare

Features Completed

  • Read JSON
  • Write JSON
  • Produce a JSON encoded error response
  • Upload files via HTTP requests with optional renaming and file type validation.
  • Download a static file
  • Get a random string of length n
  • Post JSON to a remote service
  • Create a directory, including all parent directories, if it does not already exist
  • Create a URL-safe slug from a string