Spaces:
Runtime error
Runtime error
File size: 864 Bytes
581b6d4 6f0d20b 581b6d4 6f0d20b 581b6d4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
package common
import (
"WarpGPT/pkg/logger"
fhttp "github.com/bogdanfinn/fhttp"
"github.com/gin-gonic/gin"
)
type ContextProcessor[T any] interface {
SetContext(conversation T)
GetContext() T
ProcessMethod()
}
func Do[T any](p ContextProcessor[T], conversation T) {
p.SetContext(conversation)
p.ProcessMethod()
}
func CopyResponseHeaders(response *fhttp.Response, ctx *gin.Context) {
logger.Log.Debug("CopyResponseHeaders")
if response == nil {
logger.Log.Warning("response is empty")
ctx.JSON(400, gin.H{"error": "response is empty"})
return
}
skipHeaders := map[string]bool{
"content-encoding":true,
"content-length":true,
"transfer-encoding":true,
"connection":true,
}
for name, values := range response.Header {
if !skipHeaders[name] {
for _, value := range values {
ctx.Writer.Header().Add(name, value)
}
}
}
}
|