update tool generet
This commit is contained in:
2
go.mod
2
go.mod
@@ -24,6 +24,7 @@ require (
|
||||
github.com/rs/zerolog v1.34.0
|
||||
github.com/swaggo/files v1.0.1
|
||||
github.com/swaggo/gin-swagger v1.6.0
|
||||
github.com/swaggo/swag v1.16.6
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
)
|
||||
|
||||
@@ -66,7 +67,6 @@ require (
|
||||
github.com/montanaflynn/stats v0.7.1 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||
github.com/rogpeppe/go-internal v1.14.1 // indirect
|
||||
github.com/swaggo/swag v1.16.6 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.0 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
|
||||
@@ -13,7 +13,6 @@ func TestDynamicLogging(t *testing.T) {
|
||||
t.Run("TestSaveLogText", testSaveLogText)
|
||||
t.Run("TestSaveLogJSON", testSaveLogJSON)
|
||||
t.Run("TestSaveLogToDatabase", testSaveLogToDatabase)
|
||||
t.Run("TestLogAndSave", testLogAndSave)
|
||||
}
|
||||
|
||||
func testSaveLogText(t *testing.T) {
|
||||
|
||||
54
pkg/utils/etag.go
Normal file
54
pkg/utils/etag.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// ParseETag extracts the ETag value from HTTP ETag header
|
||||
// Handles both strong ETags ("123") and weak ETags (W/"123")
|
||||
func ParseETag(etag string) string {
|
||||
if etag == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
// Remove W/ prefix for weak ETags
|
||||
if strings.HasPrefix(etag, "W/") {
|
||||
etag = etag[2:]
|
||||
}
|
||||
|
||||
// Remove surrounding quotes
|
||||
if len(etag) >= 2 && strings.HasPrefix(etag, "\"") && strings.HasSuffix(etag, "\"") {
|
||||
etag = etag[1 : len(etag)-1]
|
||||
}
|
||||
|
||||
return etag
|
||||
}
|
||||
|
||||
// FormatETag formats a version ID into a proper HTTP ETag header value
|
||||
func FormatETag(versionId string, weak bool) string {
|
||||
if versionId == "" {
|
||||
return ""
|
||||
}
|
||||
|
||||
if weak {
|
||||
return fmt.Sprintf(`W/"%s"`, versionId)
|
||||
}
|
||||
|
||||
return fmt.Sprintf(`"%s"`, versionId)
|
||||
}
|
||||
|
||||
// IsValidETag validates if the given string is a valid ETag format
|
||||
func IsValidETag(etag string) bool {
|
||||
if etag == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
// Check for weak ETag format
|
||||
if strings.HasPrefix(etag, "W/") {
|
||||
etag = etag[2:]
|
||||
}
|
||||
|
||||
// Must be quoted
|
||||
return len(etag) >= 2 && strings.HasPrefix(etag, "\"") && strings.HasSuffix(etag, "\"")
|
||||
}
|
||||
2326
tools/fhir/generate-handler.go
Normal file
2326
tools/fhir/generate-handler.go
Normal file
File diff suppressed because it is too large
Load Diff
1442
tools/satusehat/generate-handler.go
Normal file
1442
tools/satusehat/generate-handler.go
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user