Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Files" DSL for serving static assets. #490

Merged
merged 1 commit into from
May 16, 2016
Merged

Add "Files" DSL for serving static assets. #490

merged 1 commit into from
May 16, 2016

Conversation

raphael
Copy link
Member

@raphael raphael commented May 15, 2016

This DSL makes it possible to mount file servers onto controllers and
benefit from its CORS and/or security scheme.

This DSL makes it possible to mount file servers onto controllers and
benefit from its CORS and/or security scheme.
@raphael
Copy link
Member Author

raphael commented May 15, 2016

Fixes #461

@raphael
Copy link
Member Author

raphael commented May 16, 2016

This PR adds the ability to define "file servers" on resources. A file server serves static assets from the specified file path on a given route. It can serve a single file or all files under the given file path if the route ends with a wildcard starting with *. The goa cellar example takes advantage of this new DSL to serve the swagger, JSON schema, javascript and html example - see https://github.com/goadesign/goa-cellar/blob/master/design/resources.go#L7-L18. This PR removes the generation of the swagger controller - instead the design should take advantage of "Files" to specify how it should be served (as the goa-cellar example shows).

This change makes it possible to define the CORS policy and security scheme that apply to the static assets which wasn't possible before. It also helps implement a consistent strategy for serving all static assets (Swagger, JSON schema etc.) as shown in the goa-cellar example.

Note that the PR does introduce a BREAKING change and that is that the "MountSwaggerController" is no longer generated as the Swagger dummy controller is gone as noted above in favor of the controller corresponding to the resource with the "Files" DSL. So after updating goa if you see an error about this function missing simply remove its invocation from your main (or wherever) and replace it with the "Files" DSL.

As a side note - the goa-cellar makefile shows the goagen flags used to generate the swagger, JSON schema and javascript in the location that matches the design (i.e. under the /public folder) https://github.com/goadesign/goa-cellar/blob/master/Makefile#L39-L44

@raphael raphael merged commit e1d3ec0 into master May 16, 2016
@raphael raphael deleted the files_design branch June 1, 2016 04:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant