Skip to content

自定义处理异常的时候设置返回数据的content-type 但是没有生效 #112

@westoi

Description

@westoi

自定义处理异常的时候设置返回数据的content-type 但是没有生效 一直是Content-Type: text/plain; charset=utf-8,

// 异常处理
type M map[string]interface{}

func ExceptionHandle(ctx dotweb.Context, err error) {
	ctx.Response().SetContentType(dotweb.MIMEApplicationJSONCharsetUTF8)
	ctx.WriteJsonC(http.StatusInternalServerError, M{"error": err.Error()})
}
app := dotweb.New()

// 处理错误响应
app.SetExceptionHandle(ExceptionHandle)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions