remove unuse code

This commit is contained in:
wjqserver 2025-07-06 18:09:37 +08:00
parent edca87906d
commit 17bab2dcfd
2 changed files with 0 additions and 20 deletions

View file

@ -267,17 +267,6 @@ func (c *Context) String(code int, format string, values ...interface{}) {
func (c *Context) JSON(code int, obj interface{}) {
c.Writer.Header().Set("Content-Type", "application/json; charset=utf-8")
c.Writer.WriteHeader(code)
/*
// JSON 编码
jsonBytes, err := json.Marshal(obj)
if err != nil {
c.AddError(fmt.Errorf("failed to marshal JSON: %w", err))
//c.String(http.StatusInternalServerError, "Internal Server Error: Failed to marshal JSON")
c.ErrorUseHandle(http.StatusInternalServerError, fmt.Errorf("failed to marshal JSON: %w", err))
return
}
c.Writer.Write(jsonBytes)
*/
if err := json.MarshalWrite(c.Writer, obj); err != nil {
c.AddError(fmt.Errorf("failed to marshal JSON: %w", err))
c.ErrorUseHandle(http.StatusInternalServerError, fmt.Errorf("failed to marshal JSON: %w", err))
@ -294,7 +283,6 @@ func (c *Context) GOB(code int, obj interface{}) {
encoder := gob.NewEncoder(c.Writer)
if err := encoder.Encode(obj); err != nil {
c.AddError(fmt.Errorf("failed to encode GOB: %w", err))
//c.String(http.StatusInternalServerError, "Internal Server Error: Failed to encode GOB")
c.ErrorUseHandle(http.StatusInternalServerError, fmt.Errorf("failed to encode GOB: %w", err))
return
}
@ -314,7 +302,6 @@ func (c *Context) HTML(code int, name string, obj interface{}) {
err := tpl.ExecuteTemplate(c.Writer, name, obj)
if err != nil {
c.AddError(fmt.Errorf("failed to render HTML template '%s': %w", name, err))
//c.String(http.StatusInternalServerError, "Internal Server Error: Failed to render HTML template")
c.ErrorUseHandle(http.StatusInternalServerError, fmt.Errorf("failed to render HTML template '%s': %w", name, err))
}
return
@ -340,12 +327,6 @@ func (c *Context) ShouldBindJSON(obj interface{}) error {
if c.Request.Body == nil {
return errors.New("request body is empty")
}
/*
decoder := json.NewDecoder(c.Request.Body)
if err := decoder.Decode(obj); err != nil {
return fmt.Errorf("json binding error: %w", err)
}
*/
err := json.UnmarshalRead(c.Request.Body, obj)
if err != nil {
return fmt.Errorf("json binding error: %w", err)

View file

@ -554,7 +554,6 @@ func NotFound() HandlerFunc {
return func(c *Context) {
engine := c.engine
engine.errorHandle.handler(c, http.StatusNotFound, errors.New("not found"))
return
}
}