Giter Site home page Giter Site logo

Comments (8)

sporto avatar sporto commented on September 28, 2024

I am doing this manually e.g.

goweb.Map(goweb_http.MethodOptions, "/{*}", func(ctx context.Context) error {
    ctx.HttpResponseWriter().Header().Set("Access-Control-Allow-Origin", "http://localhost:9000")
    ctx.HttpResponseWriter().Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT")
    ctx.HttpResponseWriter().Header().Set("Access-Control-Allow-Headers", "origin, x-requested-with, accept")
    return nil
})

But I wonder if goweb should have some kind of convenience method to do this, if it already have one I haven't found.

from goweb.

matryer avatar matryer commented on September 28, 2024

Hmm… that's not a bad idea at all. What kind of interface would you expect?

Do you think it should go into a goweb/cores package?

On 10 Oct 2013, at 15:33, Sebastian Porto [email protected] wrote:

I am doing this manually e.g.

goweb.Map(goweb_http.MethodOptions, "/{*}", func(ctx context.Context) error {
ctx.HttpResponseWriter().Header().Set("Access-Control-Allow-Origin", "http://localhost:9000")
ctx.HttpResponseWriter().Header().Set("Access-Control-Allow-Methods", "GET, POST, PUT")
ctx.HttpResponseWriter().Header().Set("Access-Control-Allow-Headers", "origin, x-requested-with, accept")
return nil
})
But I wonder if goweb should have some kind of convenience method to do this, if it already have one I haven't found.


Reply to this email directly or view it on GitHub.

from goweb.

sporto avatar sporto commented on September 28, 2024

It would be nice to have a simple catch all method like:

goweb.AllowCORSFor(whitelistedDomains, options)

don't really know what kind of options would you pass, I haven't done too much work with CORS yet.

from goweb.

matryer avatar matryer commented on September 28, 2024

Would using a MapBefore method work better here?

On 17 Oct 2013, at 04:44, Sebastian Porto [email protected] wrote:

It would be nice to have a simple catch all method like:

goweb.AllowCORSFor(whitelistedDomains, options)
don't really know what kind of options would you pass, I haven't done too much work with CORS yet.


Reply to this email directly or view it on GitHub.

from goweb.

sporto avatar sporto commented on September 28, 2024

Sorry, closed this by mistake, when trying to comment.

Looking at the documentation MapBefore could be more flexible, or it could be some special handler you pass to Map:

goweb.Map(goweb_http.MethodOptions, "/{*}", goweb.CORSHandler(whitelistedDomains))

from goweb.

matryer avatar matryer commented on September 28, 2024

I quite like that - fancy doing a PR?

from goweb.

matryer avatar matryer commented on September 28, 2024

see https://github.com/stretchr/goweb/wiki/Development-practices

from goweb.

sporto avatar sporto commented on September 28, 2024

I would like to, if I can find the spare time to have a go I will do it. Thanks

from goweb.

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.