MCPcopy Create free account
hub / github.com/OpenCSGs/csghub-server / ContentEncoding

Function ContentEncoding

api/middleware/git_http_param.go:52–81  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

50}
51
52func ContentEncoding() gin.HandlerFunc {
53 return func(c *gin.Context) {
54 var (
55 body io.ReadCloser
56 err error
57 )
58
59 contentEncoding := c.Request.Header.Get("Content-Encoding")
60 switch contentEncoding {
61 case "":
62 body = c.Request.Body
63 case "gzip":
64 body, err = gzip.NewReader(c.Request.Body)
65 default:
66 err = fmt.Errorf("unsupported content encoding: %s", contentEncoding)
67 }
68
69 if err != nil {
70 httpbase.BadRequest(c, err.Error())
71 c.Abort()
72 return
73 }
74 defer body.Close()
75
76 c.Request.Body = body
77 c.Request.Header.Del("Content-Encoding")
78
79 c.Next()
80 }
81}
82
83func GetCurrentUserFromHeader() gin.HandlerFunc {
84 userStore := database.NewUserStore()

Callers 1

NewRouterFunction · 0.92

Calls 4

BadRequestFunction · 0.92
ErrorMethod · 0.80
CloseMethod · 0.80
GetMethod · 0.45

Tested by

no test coverage detected