You are previewing Building Web Applications with Erlang.
O'Reilly logo
Building Web Applications with Erlang

Book Description

Why choose Erlang for web applications? Discover the answer hands-on by building a simple web service with this book. If you’re an experienced web developer who knows basic Erlang, you’ll learn how to work with REST, dynamic content, web sockets, and concurrency through several examples. In the process, you’ll see first-hand that Erlang is ideal for building business-critical services.

Table of Contents

  1. Building Web Applications with Erlang
  2. Preface
    1. Who This Book Is For
    2. Learning Erlang
    3. Before You Start
    4. What You Will Learn
    5. The Limits of This Book
    6. Help! It Doesn’t Compile or Run!
      1. Diagnosing the Error
      2. What Version of Erlang and Yaws Are You Running?
      3. Is Everything Loaded Correctly?
      4. Are You Calling Everything Correctly?
      5. Is Mnesia Running with Correct Tables?
      6. Is the Example Just Plain Wrong?
    7. Conventions Used in This Book
    8. Using Code Examples
    9. Safari® Books Online
    10. How to Contact Us
    11. Acknowledgments
  3. 1. Building Scalable Systems with Erlang and REST
    1. Why Erlang?
      1. Erlang’s Advantages
      2. Lack of Types
      3. OTP—For More Than Just Telecom!
    2. Why Web Services? Why REST?
    3. New Opportunities for Scaling and Resilience
      1. Cloud Computing
      2. System Architecture and Erlang Scaling
        1. Scaling up versus scaling out
        2. Amdahl’s law
      3. Data Storage Options
        1. Mnesia
        2. CouchDB
        3. MongoDB
        4. Redis
        5. Riak
  4. 2. Getting Started with Yaws
    1. Working with Yaws
      1. Starting Yaws
      2. Serving Static Files
      3. Compiling, Loading, and Running Code
      4. Clustering Yaws
    2. Dynamic Content in Yaws
      1. EHTML
      2. Headers and Redirects
    3. Templates
      1. ErlyDTL
    4. Logging
      1. Erlang OTP error_logger
  5. 3. Appmods: Dynamic Content in Yaws
    1. Appmod Configuration
    2. When the URI Does Not Correspond to a File
    3. Cookies
    4. Session Handling
    5. Access Control
    6. Interacting with Erlang Services and Business Logic Layers
  6. 4. Implementing REST
    1. Decoding a Request
      1. Extracting the User’s Request
    2. Response and Headers
    3. Building the Response
      1. JSON
      2. XML
    4. Responding to the REST Request
    5. A Full Example
  7. 5. File Upload
    1. The File Upload Request
    2. Saving to Disk
    3. Putting It All Together
    4. Storage in a Distributed System
    5. Saving to Amazon S3
  8. 6. WebSockets
    1. The WebSocket Request
    2. Basic WebSocket Handler
    3. Advanced WebSocket Handler
  9. 7. Streaming
    1. Simple Streaming
  10. 8. Using the HTTP Client
    1. Making a Request
    2. Using OAuth
      1. Facebook Canvas
  11. 9. Building an Application with OTP
    1. Directory Structure
    2. Building an Application Server
    3. The Generic Server
    4. The Multicast Server
    5. Interfacing the Server with the Web
    6. Some Client-Side Code
    7. Let’s Have Some Adult Supervision Around Here!
    8. A Little Optimization
    9. Bundling as an Application
    10. The App File
    11. Wrapping Up OTP
  12. A. Installing Erlang and Yaws
  13. B. Beyond Yaws
    1. Web Servers
      1. Cowboy
      2. MochiWeb
      3. Misultin
    2. Web Frameworks
      1. Chicago Boss
      2. Nitrogen
      3. Zotonic
  14. C. Interfacing with Ruby and Python
    1. Ruby
    2. Python
  15. D. Using Erlang with Emacs
    1. Distel
    2. Flymake Mode
    3. Gen Server Template
  16. About the Author
  17. Copyright