https://github.com/pei0804/goa-spa-sample
https://github.com/pei0804/goa-spa-sample
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/pei0804/goa-spa-sample
- Owner: pei0804
- License: mit
- Created: 2017-08-20T07:30:19.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-24T17:15:44.000Z (almost 9 years ago)
- Last Synced: 2026-01-02T03:40:19.872Z (5 months ago)
- Language: JavaScript
- Size: 3.45 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Files
This example shows how to build an API that serves static assets.
The file [generate.go](generate.go) contains `go generate` directives that uses `goagen` to generate
the necessary files. Run it with:
```bash
go generate
```
Then compile and run the service:
```bash
go build
./files
```
## Resources
This example contains the following two resources.
* schema
* swagger
### Schema
The `schema` resource contains a single endpoint which serves the static files contained in the `public/schema` directory. This means the directory must exist and its relative path must be `public/schema`.
### Swagger
The `swagger` resource also contains a single endpoint however it leverages [https://github.com/elazarl/go-bindata-assetfs](https://github.com/elazarl/go-bindata-assetfs) to serve assets embedded within the compiled binary.
* [go-bindata](https://github.com/jteeuwen/go-bindata) is
> A small utility which generates Go code from any file. Useful for embedding binary data in a Go program.
* [go-bindata-assetfs](https://github.com/elazarl/go-bindata-assetfs)
> Serves embedded files from `jteeuwen/go-bindata` with `net/http`.
Using these packages alleviates the need for deploying the `public/swagger` directory.