status_code=status.HTTP_201_CREATED, payload_key='user', service_url=settings.USERS_SERVICE_URL, authentication_required=True, post_processing_func=None, authentication_token_decoder='auth.decode_access_token', service_authorization_checker='auth.is_admin_user', service_header_generator='auth.generat...
You can start with the microservice code. The Marketplace microservice will be a Flask app to display a webpage to the user. It’ll call the Recommendations microservice to get book recommendations to display on the page. Open the marketplace/marketplace.py file and add the following: Pyth...
decode('utf-8') return 'Hello Linode! This page has been viewed %s time(s).' % count @app.route('/resetcounter') def resetcounter(): cache.delete('visitor_count') PgFetch("UPDATE visitors set visitor_count = 0 where site_id = 1;", "POST") app.logger.debug("reset visitor count...
When using the client, you are able to easily decode errors using theErrorDecoderinterface with the receivedResponseobject when the HTTP code is not in the 200 range. Now, we only need a way to map the errors to the proper exception. Required base exception Most of our exceptions here at ...
Because the service doesn’t have a dedicated database, create ausers.jsonfile in the root directory of your project to store a list of authorized users. Paste the code below in the file: [{"id":1,"username":"admin","password":"admin"}] ...
Now on to the code. I’m not trying to teach basic Android programming here, so I’ll just focus on the Lambda-specific elements of this app. (If you’re creating your own, you’ll also need to include the AWS Mobile SDK jar to run the sample code below.) Conceptually there are ...
Our “business logic” is going to be the listing and creation of products, and that code will be part of the following functions: func handleProductPost(w http.ResponseWriter, r *http.Request) { var product Product err := json.NewDecoder(r.Body).Decode(&product) if err != nil { http...
The sample provisions AWS resources via theAWS Cloud Development Kit (CDK). The CDK code is provided in C# so that .NET developers can use a familiar language. The solution deployment steps include: Configuring a domain name in Route 53. ...
(step 2) to aVerifyendpoint of the microservice, using the connection information that the service provided. This is thehttp_client.fetchline in the post method of the code above. The server sends a knownchallengequery, and the service must send back a pre-agreedresponse. The response from...
Nancy also can do XML. In fact, Nancy has a full “Content Negotiation” algorithm built into it, and if you change your route handler so that it simply just returns the “test” object in the previous code, Nancy will actually try to figure out what the best format to return is. ...