Clojure Web Development Essentials
eBook - ePub

Clojure Web Development Essentials

Ryan Baldwin

Condividi libro
  1. 232 pagine
  2. English
  3. ePUB (disponibile sull'app)
  4. Disponibile su iOS e Android
eBook - ePub

Clojure Web Development Essentials

Ryan Baldwin

Dettagli del libro
Anteprima del libro
Indice dei contenuti
Citazioni

Domande frequenti

Come faccio ad annullare l'abbonamento?
È semplicissimo: basta accedere alla sezione Account nelle Impostazioni e cliccare su "Annulla abbonamento". Dopo la cancellazione, l'abbonamento rimarrà attivo per il periodo rimanente già pagato. Per maggiori informazioni, clicca qui
È possibile scaricare libri? Se sì, come?
Al momento è possibile scaricare tramite l'app tutti i nostri libri ePub mobile-friendly. Anche la maggior parte dei nostri PDF è scaricabile e stiamo lavorando per rendere disponibile quanto prima il download di tutti gli altri file. Per maggiori informazioni, clicca qui
Che differenza c'è tra i piani?
Entrambi i piani ti danno accesso illimitato alla libreria e a tutte le funzionalità di Perlego. Le uniche differenze sono il prezzo e il periodo di abbonamento: con il piano annuale risparmierai circa il 30% rispetto a 12 rate con quello mensile.
Cos'è Perlego?
Perlego è un servizio di abbonamento a testi accademici, che ti permette di accedere a un'intera libreria online a un prezzo inferiore rispetto a quello che pagheresti per acquistare un singolo libro al mese. Con oltre 1 milione di testi suddivisi in più di 1.000 categorie, troverai sicuramente ciò che fa per te! Per maggiori informazioni, clicca qui.
Perlego supporta la sintesi vocale?
Cerca l'icona Sintesi vocale nel prossimo libro che leggerai per verificare se è possibile riprodurre l'audio. Questo strumento permette di leggere il testo a voce alta, evidenziandolo man mano che la lettura procede. Puoi aumentare o diminuire la velocità della sintesi vocale, oppure sospendere la riproduzione. Per maggiori informazioni, clicca qui.
Clojure Web Development Essentials è disponibile online in formato PDF/ePub?
Sì, puoi accedere a Clojure Web Development Essentials di Ryan Baldwin in formato PDF e/o ePub, così come ad altri libri molto apprezzati nelle sezioni relative a Informatique e Programmation Open Source. Scopri oltre 1 milione di libri disponibili nel nostro catalogo.

Informazioni

Anno
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...

Indice dei contenuti