mirror of
https://github.com/nabbar/golib.git
synced 2025-12-24 11:51:02 +08:00
Add feature to change http timeout directly in httpcli store in aws client Add copy/MPUCopy function Update mpu to allow copy with MPU Package Cobra Fix println by fmt.Fprint to os.stdout Package Crypt Refactor package to use instance of crypt instead of a global crypt unique instance Allow to gen key/nonce Add io stream reader/writer instead of only buffer slice encoder decoder Package file/bandwidth Add new subpackage bandwith to limit a amount of byte read/write for a duraction Use file/progress function increment/reset Allow to add custom function increment / reset Package IOUtils Remove useless file error.go, tempFile.go (replaced by package file) Move fileDescriptor to a subpackage fileDescriptor: allow to change nb of FD for linux/windows os Move Buffer ReadCloser to a new subpackage: allow to add close function to buffer, and expose read / write io interface Add sub package multiplexer to allow send/receive multiple io stream into on io stream Package Socket Rework to expose io stream instead of buffer Fix minor bugs Other: Bump dependencies Update code following bump dependencies
Package Static
This package help to manage static file router in an API to embedded files into the go binary api.
This package requires packr tools, golib/router & go Gin Tonic API Framework.
Example of implementation
We will work on an example of file/folder tree like this :
/
bin/
api/
config/
routers/
static/
get.go
static/
static/
...some_static_files...
in the get.go file, we will implement the static package call :
package static
import (
"github.com/gin-gonic/gin"
"github.com/gobuffalo/packr"
"github.com/nabbar/golib/static"
"myapp/release"
"myapp/bin/api/config"
"myapp/bin/api/routers"
)
const UrlPrefix = "/static"
func init() {
staticStcFile := static.NewStatic(false, UrlPrefix, packr.NewBox("../../../../static/static"), GetHeader)
staticStcFile.SetDownloadAll()
staticStcFile.Register(routers.RouterList.Register)
}
func GetHeader(c *gin.Context) {
// any function to return global & generic header (like CSP, HSTS, ...)
}