Clojure Web Development Essentials
eBook - ePub

Clojure Web Development Essentials

Ryan Baldwin

Compartir libro
  1. 232 páginas
  2. English
  3. ePUB (apto para móviles)
  4. Disponible en iOS y Android
eBook - ePub

Clojure Web Development Essentials

Ryan Baldwin

Detalles del libro
Vista previa del libro
Índice
Citas

Preguntas frecuentes

¿Cómo cancelo mi suscripción?
Simplemente, dirígete a la sección ajustes de la cuenta y haz clic en «Cancelar suscripción». Así de sencillo. Después de cancelar tu suscripción, esta permanecerá activa el tiempo restante que hayas pagado. Obtén más información aquí.
¿Cómo descargo los libros?
Por el momento, todos nuestros libros ePub adaptables a dispositivos móviles se pueden descargar a través de la aplicación. La mayor parte de nuestros PDF también se puede descargar y ya estamos trabajando para que el resto también sea descargable. Obtén más información aquí.
¿En qué se diferencian los planes de precios?
Ambos planes te permiten acceder por completo a la biblioteca y a todas las funciones de Perlego. Las únicas diferencias son el precio y el período de suscripción: con el plan anual ahorrarás en torno a un 30 % en comparación con 12 meses de un plan mensual.
¿Qué es Perlego?
Somos un servicio de suscripción de libros de texto en línea que te permite acceder a toda una biblioteca en línea por menos de lo que cuesta un libro al mes. Con más de un millón de libros sobre más de 1000 categorías, ¡tenemos todo lo que necesitas! Obtén más información aquí.
¿Perlego ofrece la función de texto a voz?
Busca el símbolo de lectura en voz alta en tu próximo libro para ver si puedes escucharlo. La herramienta de lectura en voz alta lee el texto en voz alta por ti, resaltando el texto a medida que se lee. Puedes pausarla, acelerarla y ralentizarla. Obtén más información aquí.
¿Es Clojure Web Development Essentials un PDF/ePUB en línea?
Sí, puedes acceder a Clojure Web Development Essentials de Ryan Baldwin en formato PDF o ePUB, así como a otros libros populares de Informatique y Programmation Open Source. Tenemos más de un millón de libros disponibles en nuestro catálogo para que explores.

Información

Año
2015
ISBN
9781784392222

Clojure Web Development Essentials


Table of Contents

Clojure Web Development Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Getting Started with Luminus
Leiningen
Using Leiningen
Generating the application
Getting help
Dependencies of the app
Luminus file structure
util.clj
session_manager.clj
layout.clj
middleware.clj
routes/home.clj
handler.clj
repl.clj
Summary
2. Ring and the Ring Server
Understanding Ring in Clojure
Request maps
Response maps
Handlers
Middleware
Adapters
What is the Ring Server?
hipstr.handler
Initialization hooks
Shutdown hooks
App routes
The application handler
hipstr.repl
Start-server
Stop-server
Get-handler
Configuring and running the Ring Server
Summary
3. Logging
What is Timbre?
What is an appender?
Configuring a Timbre appender
Timbre log levels
Appender configuration keys
Appender map
Shared appender configuration
Logging with Timbre
Adding an appender
Adding the rolling appender
Summary
4. URL Routing and Template Rendering
What is Compojure?
Creating a Compojure route
Using defroutes
Anatomy of a route
Defining the method
Defining the URL
Parameter destructuring
Destructuring the request
Destructuring unbound parameters
Constructing the response
Generating complex responses
What is Selmer?
Creating your first page
Rendering a page
Variables
Filters
Filter parameters
Tags
Template inheritance
Editing the home page
Serving the signup form
Creating the signup page
Summary
5. Handling Form Input
Handling the form POST
Validating the form POST
The noir.validation namespace
The Validateur library
Adding the Validateur dependency
Creating the user validation namespace
Validating required fields
Validating the format
Validating length of values
Validation predicates
Making reusable validators
Reporting errors to the user
Summary
6. Testing in Clojure
The necessity of testing
Anatomy of a test
Writing and running our first test
Running tests
Running tests automatically
Refactoring tests
Writing a high-level integration test
Using ring.mock.request
Summary
7. Getting Started with the Database
Creating the database schema
Maintaining the database schema
Migratus
Getting Migratus
Configuring Migratus
Creating the user table
Dropping the user table
Running the down scripts
Migrating the database
Running all migration scripts from Leiningen
Running migrations programatically
Adding migrations to the hipstr initialization
Adding data to the database
What is YeSQL?
Getting YeSQL
Adding a user to the database
Inserting a user using SQL
Inserting a user using Clojure
Bringing it all together
Adjusting the route
Encrypting the password
Summary
8. Reading Data from the Database
Creating the catalog
Creating the artists table
Seeding the artists table
Creating the albums table
Fetching albums from the database
Writing the SQL query
Creating the albums model
Refactoring the connection
Creating the recently added route
Rendering the results
An exercise!
Summary
9. Database Transactions
Introduction to Database Transactions
The ACID properties
Importance of database transactions
Implementing a transaction
Transactions in Clojure
Transactions in YeSQL
Extending the application requirements in brief
Creating the add artist/album form
Creating the form
Abstracting the form
Creating the add artist/album endpoint
Creating the Compojure route
Creating the route helper function
Validating the add artist/album form
Expanding the album model
Wrapping the whole thing in a transaction
Using a transaction outside of this scope
Summary
10. Sessions and Cookies
Sessions
Setting up sessions
Interacting with the session
Restricted routes
Restricting route access
Accessing a restricted route
Access rule as a function
Access rule as a map
Cookies
Getting a cookie's value
Setting a cookie's value
Setting the cookie as a map
Securing a cookie
Deleting a cookie
Extending the application: brief requirements
Creating the login form
Restricting the recently-added route
Restricting the route
Checking if the user is authenticated
Defining the access rule
Authenticating the user
Validating the credentials
Handling the form POST
Writing the "Remember Me" cookie
Creating the logout route
Summary
11. Environment Configuration and Deployment
Environ
Using environ
Variable translations
Setting and resolving environment configurations
Resolving environment configuration
Adjusting the database connection
Creating the profiles.clj file
Modifying the hipstr.models.connection namespace
Deploying the hipstr application
When to use an uberjar
When to use an uberwar
Deploying as a standalone
Running the application behind Nginx
Load balancing behind Nginx
Summary
A. Using Korma – a Clojure DSL for SQL
Getting Korma
The Quick Korma Crash Course
Define the database specification
Korma entities
Defining the primary key
Defining relationships between entities
Constructing SELECT queries
Constructing INSERT queries
Constructing UPDATE queries
Constructing DELETE queries
Using raw SQL
Using transactions
Port the models from YeSQL to Korma
Porting hisptr.models.connection
Porting hisptr.models.user-model
Porting hipstr.models.album-model
Index

Clojure Web Development Essentials

Copyright © 2015 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedd...

Índice