- Documentar a API.
- mkdir group-orders-api
- cd group-orders-api
- git init
- mkdir tests
| #!/bin/sh | |
| go fmt ./... |
| #!/bin/sh | |
| status=0 | |
| failing_tests="$(go test ./... | grep "FAIL:" | awk '{print $3}')" | |
| if test -n "$failing_tests" ; then | |
| for fail in $failing_tests; do | |
| echo "git pre-push check failed: go test failed: $fail" | |
| done | |
| status=1 | |
| fi |
| [Desktop Entry] | |
| Name=Robomongo | |
| GenericName=Robomongo | |
| Exec=/opt/robomongo/bin/robomongo | |
| Terminal=false | |
| Icon=/opt/robomongo/icons/robomongo123.png | |
| Type=Application | |
| Categories=Application; | |
| Comment=Robomongo |
| [Desktop Entry] | |
| Name=Firefox Developer | |
| GenericName=Firefox Developer Edition | |
| Exec=/opt/firefox_dev/firefox | |
| Terminal=false | |
| Icon=/opt/firefox_dev/browser/icons/mozicon128.png | |
| Type=Application | |
| Categories=Application;Network;X-Developer; | |
| Comment=Firefox Developer Edition Web Browser. |
| docker pull consul | |
| docker run -d --name=dev-consul -p 8500:8500 consul | |
| firefox localhost:8500 |
| # hooks/auth.py | |
| import falcon | |
| from api.models.user_token import UserToken | |
| def authorize(): | |
| def hook(req, resp, resource, params): | |
| token = req.context.get('token') | |
| if token is None: | |
| description = ('Please provide an auth token as part of the request.') | |
| raise falcon.HTTPUnauthorized('Auth token required', 'Auth token required', description, href='http://docs.example.com/auth') |
| # middlewares/json_translator.py | |
| import json | |
| import falcon | |
| class JSONTranslatorMiddleware(object): | |
| def process_request(self, req, resp): | |
| if req.content_length in (None, 0): | |
| return | |
| body = req.stream.read() | |
| if not body: |
| # app.py | |
| import falcon | |
| import json | |
| class SongsResource: | |
| def on_get(self, req, resp): | |
| songs = [ | |
| { | |
| "title": "Your Song", "artist": "Elton John" |
| 'use strict'; | |
| /* https://github.com/angular/protractor/blob/master/docs/toc.md */ | |
| describe('my app', function() { | |
| it('should automatically redirect to /sign-up when location hash/fragment is empty', function() { | |
| browser.get('index.html'); | |
| expect(browser.getLocationAbsUrl()).toMatch("/sign-in"); | |
| }); |