Comments (8)
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.
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.
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.
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.
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.
I quite like that - fancy doing a PR?
from goweb.
see https://github.com/stretchr/goweb/wiki/Development-practices
from goweb.
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)
- make controller mapping methods configurable HOT 1
- Add ability to store state in handlers
- RestfulManyUpdater has wrong mapping HOT 5
- Don't envelop data in responses by default HOT 9
- Remove unnecessary stuff from APIResponder interface
- What would be the most elegant way to mix RESTful API and some HTML rendering views? HOT 4
- Example for injecting database into context HOT 5
- Simplified API in the future? Goweb use too many []interface{} for args HOT 4
- The server's binary gets all the test flags HOT 5
- Gzip Compression HOT 3
- Figure out real status with always200 HOT 1
- web_context.go's FileExtention also returns query parameters HOT 1
- Dotted urls may confuse goweb parameters HOT 2
- Over-eager path matching HOT 2
- panic with index out of range when call PathPattern.GetPathMatch HOT 2
- BeforeHandler.Before() where are errors returned to? HOT 3
- Testing Controllers?
- Why aren't dotted values allowed for resource ids? HOT 2
- putting controllers in different files HOT 1
- SSL Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from goweb.