GithubHelp home page GithubHelp logo

Comments (2)

savsgio avatar savsgio commented on July 19, 2024 2

Because actx inherits the method of ctx, so can use the ctx.method, Is the effect the same?

Yes, It's explained on README 😄

And I've just added custom error view in configuration, so you could configure it with something like that:

config := &atreugo.Config{
		...
		ErrorView: func(ctx *atreugo.RequestCtx, err error, statusCode int) {
			ctx.JSONResponse(atreugo.JSON{"code": statusCode, "msg": err.Error()}, statusCode)
		},
                ...
	}

from atreugo.

imxxiv avatar imxxiv commented on July 19, 2024

utils.go line 38 ctx.Error(err.Error(), fasthttp.StatusInternalServerError)

func viewToHandler(view View) fasthttp.RequestHandler {
	return func(ctx *fasthttp.RequestCtx) {
		actx := acquireRequestCtx(ctx)

		if err := view(actx); err != nil {
			ctx.Error(err.Error(), fasthttp.StatusInternalServerError)
		}

		releaseRequestCtx(actx)
	}
}

router.go line 99 actx.Error(err.Error(), statusCode)

		if err != nil {
			r.log.Error(err)
			actx.Error(err.Error(), statusCode)
		}

Because actx inherits the method of ctx, so can use the ctx.method, Is the effect the same?

from atreugo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.