In this video, Keith Casey applies the concepts from earlier in the course including updating our routing, simple payload handling including JSON parsing, show simple content negotiation (more middleware), use proper response codes.
- [Teacher] So far, our API has been read only,…let's change that.…By the way, at this point it worth noting that all the…requests to our API have to use a barer token now, remember,…the authentication middleware?…In postman, here's what that looks like.…So we have the get, we have a header, and that header…is labeled authorization and has the token.…So we can hit send here all we want, and it works…as expected.…Let's get back to the code.…So, as noted in earlier portions, we know that our route…will be post messages to create a new message,…but is that enough?…Well let's find out.…
Let's copy our existing route to a new one, get rid of…everything inside, change this to post, and then we need…to start filling in the details.…So, we'll go ahead and get the message, message equals…request, get message.…So we're assuming that one of the fields coming across…in the post will be something called message.…In fact, let's make sure we can actually get the request…by feeding it into the function.…Now, we have that available to us.…
This course begins with a simple application specification and builds it one step at a time. Each chapter includes a key concept, with examples from other public APIs, and then shows how to build it yourself with Silex. Learn about URL routing, validating input, and generating response codes and hypermedia payloads. Like any project, the first implementation may be a little messy, but don't worry. The last chapter covers refactoring and what it takes to scale and support the API going forward.
- Understanding the project goals
- Adding authentication with Silex
- Using cross-framework and authentication middleware
- Creating a read-write API in Silex
- Uploading files via an API
- Adding file security
- Creating payloads and response codes in Silex
- Scaling your API