Clojure Web Development Essentials
eBook - ePub

Clojure Web Development Essentials

Ryan Baldwin

Partager le livre
  1. 232 pages
  2. English
  3. ePUB (adapté aux mobiles)
  4. Disponible sur iOS et Android
eBook - ePub

Clojure Web Development Essentials

Ryan Baldwin

DĂ©tails du livre
Aperçu du livre
Table des matiĂšres
Citations

Foire aux questions

Comment puis-je résilier mon abonnement ?
Il vous suffit de vous rendre dans la section compte dans paramĂštres et de cliquer sur « RĂ©silier l’abonnement ». C’est aussi simple que cela ! Une fois que vous aurez rĂ©siliĂ© votre abonnement, il restera actif pour le reste de la pĂ©riode pour laquelle vous avez payĂ©. DĂ©couvrez-en plus ici.
Puis-je / comment puis-je télécharger des livres ?
Pour le moment, tous nos livres en format ePub adaptĂ©s aux mobiles peuvent ĂȘtre tĂ©lĂ©chargĂ©s via l’application. La plupart de nos PDF sont Ă©galement disponibles en tĂ©lĂ©chargement et les autres seront tĂ©lĂ©chargeables trĂšs prochainement. DĂ©couvrez-en plus ici.
Quelle est la différence entre les formules tarifaires ?
Les deux abonnements vous donnent un accĂšs complet Ă  la bibliothĂšque et Ă  toutes les fonctionnalitĂ©s de Perlego. Les seules diffĂ©rences sont les tarifs ainsi que la pĂ©riode d’abonnement : avec l’abonnement annuel, vous Ă©conomiserez environ 30 % par rapport Ă  12 mois d’abonnement mensuel.
Qu’est-ce que Perlego ?
Nous sommes un service d’abonnement Ă  des ouvrages universitaires en ligne, oĂč vous pouvez accĂ©der Ă  toute une bibliothĂšque pour un prix infĂ©rieur Ă  celui d’un seul livre par mois. Avec plus d’un million de livres sur plus de 1 000 sujets, nous avons ce qu’il vous faut ! DĂ©couvrez-en plus ici.
Prenez-vous en charge la synthÚse vocale ?
Recherchez le symbole Écouter sur votre prochain livre pour voir si vous pouvez l’écouter. L’outil Écouter lit le texte Ă  haute voix pour vous, en surlignant le passage qui est en cours de lecture. Vous pouvez le mettre sur pause, l’accĂ©lĂ©rer ou le ralentir. DĂ©couvrez-en plus ici.
Est-ce que Clojure Web Development Essentials est un PDF/ePUB en ligne ?
Oui, vous pouvez accĂ©der Ă  Clojure Web Development Essentials par Ryan Baldwin en format PDF et/ou ePUB ainsi qu’à d’autres livres populaires dans Informatique et Programmation Open Source. Nous disposons de plus d’un million d’ouvrages Ă  dĂ©couvrir dans notre catalogue.

Informations

Année
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...

Table des matiĂšres