Chapter 8. Developing Swift Middleware

Jon Solera

Using nothing more than the default Swift installation, you can solve many of the challenges of distributed storage. In case that doesn’t meet your needs, Swift ships with several helpful middleware packages to extend the functionality of your Swift installation. However, sometimes developers must address specific, custom requirements. Swift’s open design makes it easy to add your own significant new functionality through middleware, with comparatively little effort. Middleware is a great way to customize Swift to meet your particular needs.

Middleware does have its complications, however. This chapter aims to provide you with a conceptual overview of how Swift middleware works. Swift is built on Python’s Web Services Gateway Interface (WSGI) model, and is configured using the Python Paste framework, both of which require some attention. Middleware can be somewhat counterintuitive, as it “wraps” core Swift (and other layers of middleware). So in a sense, you need to design your system inside out—requests will be passed through layers of middleware and possibly altered at each stage before reaching core Swift. After providing this background, this chapter will then acquaint you with how to write Swift middleware, and will work through a range of examples. Finally, we’ll give you some ideas about how you might use middleware.

Introduction to WSGI

The WSGI framework is a fundamental component of Swift’s architecture. Developers have good ...

Get OpenStack Swift now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.