Skip to content

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

Closed

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)

Activity

  1. added 2 commits that reference this issue on Mar 28, 2018
  2. devfeel commented on Mar 28, 2018

    @devfeel
    Owner

    fixed on version 1.4.9.2

  3. westoi commented on Mar 28, 2018

    @westoi
    Author

    不止app.SetExceptionHandle,还包括SetMethodNotAllowedHandle和SetNotFoundHandle @devfeel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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