Giter Club home page Giter Club logo

Comments (7)

adg avatar adg commented on August 18, 2024

Could do this with a custom error type:

type HTTPError struct {
  Err error
  StatusCode int
}

from go-endpoints.

x1ddos avatar x1ddos commented on August 18, 2024

But those are already defined in https://github.com/GoogleCloudPlatform/go-endpoints/blob/master/endpoints/errors.go

For instance, you could do return endpoints.UnauthorizedError if you wanted to respond with 401.

Or is it something else?

from go-endpoints.

dhermes avatar dhermes commented on August 18, 2024

DERP. My bad. I just ASSumed they weren't defined since endpoints.CurrentUser doesn't use them.

I suppose I should change the issue title to: Document custom errors and use 401 / 403 for relevant auth errors. WDYT?

from go-endpoints.

x1ddos avatar x1ddos commented on August 18, 2024

@dhermes yeah, I think it's a good idea! We should revise all returned errors. I think we were returning those generic errors because the pre-defined ones didn't exist at that point.

from go-endpoints.

zboralski avatar zboralski commented on August 18, 2024

We should remove the requirement that the Error messages begin by their equivalent StatusText... Right now if you create a new NotFound error, it will revert to a 400 unless it starts by "Not Found"... I'll post a pr later.

from go-endpoints.

 avatar commented on August 18, 2024

Java 401 error implementation
OAuth Protecting a method https://cloud.google.com/appengine/docs/java/endpoints/getstarted/backend/code_walkthrough#oauth_protecting_a_method
Live demo https://apis-explorer.appspot.com/apis-explorer/?base=https://cloudendpointstic.appspot.com/_ah/api#p/tictactoe/v1/tictactoe.scores.insert Execute without OAuth

from go-endpoints.

zboralski avatar zboralski commented on August 18, 2024

There is a related issue already...

#110

Right if error message are not prefixed by the standard http status code's text then are turned into 400.

from go-endpoints.

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.