Skip to content

Version v2.0.0 Release Notes

Latest
Compare
Choose a tag to compare
@rozdolsky33 rozdolsky33 released this 28 Sep 15:15
· 15 commits to main since this release

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"`
      }