D Web Development - Kai Nacke - E-Book

D Web Development E-Book

Kai Nacke

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Leverage the power of D and the vibe.d framework to develop web applications that are incredibly fast

About This Book

  • Utilize the elegant vibe.d framework to build web applications easily and REST backends with the D programming language
  • Learn about all components of vibe.d to enhance your web development with D
  • A hands-on guide to the vibe.d framework; from static web pages to template-based, interactive and localized web applications with database access and REST backends

Who This Book Is For

Whether you are new to the world of D, or already have developed applications in D, or if you want to leverage the power of D for web development, then this book is ideal for you. Basic knowledge of core web technologies like HTML 5 is helpful but not required. This book explains the difficult details to speed your web development.

What You Will Learn

  • Create amazingly fast web applications with D
  • Use Diet templates to easily create a web user interface
  • Utilize the web framework for interactive applications with input validation and internationalization
  • Access a database to provide persistent storage for your application
  • Extend your application with a REST interface and access other applications via REST
  • Understand vibe.d's fiber-based approach to asynchronous I/O and use it for integration of existing components
  • Create GUI applications with vibe.d

In Detail

D is a programming language with C-like syntax and static typing. The vibe.d framework builds on powerful D concepts like template meta-programming and compile-time function execution to provide an easy-to-use environment for web applications. The combination of a feature-rich web programming framework with a language compiling to native code solves two common issues in web development today: it accelerates your development and it results in fast, native web applications. Learning the vibe.d framework before you start your application will help you to choose the right features to reach your goal.

This book guides you through all aspects of web development with D and the vibe.d framework.

Covering the popular operating systems today, this guide starts with the setup of your development system. From the first Hello World-style application you will move on to building static web pages with templates. The concise treatment of web forms will give you all the details about form handling and web security. Using the abstractions of the web framework you will learn how to easily validate user input. Next, you will add database access to your application, providing persistent storage for your data. Building on this foundation, you will expose your component and integrate other components via REST. Learning about the internals of vibe.d you will be able to use low-level techniques such as raw TCP access. The vibe.d concepts can also be used for GUI clients, which is the next topic that you will learn. vibe.d is supported by an active community, which adds new functionality. This comprehensive guide concludes with an overview of the most useful vibe.d extensions and where to find them. It also shows you how to integrate these extensions in your application.

The concepts are always illustrated with source code, giving you an insight into how to apply them in your application.

Style and approach

A tutorial-style guide to develop web applications with D and the vibe.d framework. Each topic is explained in detail and illustrated with source code, providing you with hands-on assistance for your application.

Sie lesen das E-Book in den Legimi-Apps auf:

Android
iOS
von Legimi
zertifizierten E-Readern

Seitenzahl: 216

Veröffentlichungsjahr: 2016

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Table of Contents

D Web Development
Credits
Foreword
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
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with Your First Web Application
Installing the D compiler and the DUB package manager
Ubuntu and Debian
Fedora
OS X
Windows
Building from source
Verifying your environment
Creating your first web application
Using DUB to set up the project structure
Creating your first template
Summary
2. Using Templates for Your Web Pages
Benefits of using templates
Creating your first template
Turning the HTML page into a Diet template
Adding inheritance
Using includes
Integrating other languages with blocks and filters
Solving common tasks
Configuring the document type
Comments in a template
More about tags
Localizing your website
Adding D code to your template
Summary
3. Get Interactive – Forms and Flow Control
Introducing the note application
Creating a template with a simple form
A closer look at route matching
Serving static files
Storing session data
Authenticating the user
Using basic authentication
Using digest authentication
Form-based authentication
Enabling TLS/SSL with your application
Displaying an error page
Uploading files
Summary
4. Easy Forms with the Web Framework
Taking advantage of unique D features
Converting the note application
Naming the handler functions
Passing values of form fields
Creating sessions and session variables
Putting everything together
Validating user input
Displaying error messages with @errorDisplay
Refining the validation
Adding authentication
Localizing the web content
Summary
5. Accessing a Database
Choosing the right database technology
Relational databases
A key-value store
Document databases
Making a choice
Using the Redis key-value store
Installing Redis
Accessing Redis from the note application
Using the MongoDB document database
Installing MongoDB
Persisting data with MongoDB
Using the MySQL relational database
Installing MySQL
Using MySQL with vibe.d
Summary
6. Using the REST Interface
Defining the principles of the World Wide Web
Serializing D to JSON and back
Creating and using a REST service
Providing a service
Using a service
Tailoring the generated REST API
Changing the generated path
Passing parameters
Accessing CouchDB
Installing CouchDB
Testing the REST interface
Implementing the NoteStore service
Summary
7. The vibe.d Internals
The programming model of vibe.d
What is a fiber?
Benefits of asynchronous I/O
Combining threads, fibers, and asynchronous I/O
Coding your own main function
Performing background work
Running a fiber-based task
Using a thread
Porting an existing driver
An alternative solution for the existing drivers
Summary
8. Using vibe.d with a GUI Client
The GUI event loop and vibe.d
Creating a Win32 GUI application
Creating an X11 GUI application
Integrating with other GUI toolkits
Summary
9. Power Your Application with vibe.d Extensions
Publishing your project in the DUB registry
Useful community projects
Adding WebDAV services
Running your own blog
Chatting with IRC
Coding for the Internet of Things
Serving news
Accessing the Apache Cassandra database
Summary
Index

D Web Development

D Web Development

Copyright © 2016 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 embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

First published: January 2016

Production reference: 1250116

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham B3 2PB, UK.

ISBN 978-1-78528-889-0

www.packtpub.com

Credits

Author

Kai Nacke

Reviewers

Orfeo Da Vià

Stephan Dilly

Paul Féraud

Kazuki Komatsu

Adam D. Ruppe

Robert "burner" Schadek

Acquisition Editor

Tushar Gupta

Content Development Editor

Merwyn D'souza

Technical Editor

Pranil Pathare

Copy Editor

Tasneem Fatehi

Project Coordinator

Neha Bhatnagar

Proofreader

Safis Editing

Indexer

Mariammal Chettiyar

Production Coordinator

Arvindkumar Gupta

Cover Work

Arvindkumar Gupta

Foreword

As a general-purpose language, D has held good potential of being applied in the burgeoning web server domain. D's build speed makes its convenience close to that of scripting languages—the argument goes—and there's also a lot to like about the running speed of the resulting native code, too.

This has remained a theoretical possibility for a good while, until vibe.d came out of nowhere to take the D community by storm. The vibe.d framework is everything that I'd hoped it to be—a comprehensive, compelling, modern framework that wonderfully uses D's features to strike a balance between flexibility, performance, and ease of use.

It is everything I hoped... except for one thing. It doesn't have a good book teaching it properly. Therefore, it's easy to imagine my giddiness now that I was offered the honor to write this foreword for such a book.

Written by Kai Nacke, a long-standing and respected luminary of the D community (known among other things for LDC, the LLVM-based D compiler), D Web Development does an admirable job of taking its reader from not knowing much about web development (as I confess your truly is, or at least was) to getting a high-performance server up and running. Also, customizing it in so many ways: content, localization, data connectivity, interoperation, and defining extensions.

Since its creation, vibe.d has slowly but surely become one of the most important frameworks written in D and simultaneously one of the best examples of using D on large scale, so much so that vibe.d is being made part of the reference D distribution. This book is a necessary and welcome term of that equation.

Andrei Alexandrescu

Co-developer of the D programming language

About the Author

Kai Nacke is a professional IT architect living in Düsseldorf, Germany. He holds a diploma in computer science from the University of Dortmund. His diploma thesis about universal hash functions was recognized as the best of the semester. He has been with IBM for more than 15 years, and has great experience in the development and architecture of business and enterprise applications.

Fascinated by the first home computer, he learned to program a VIC-20 in BASIC. Later, he turned to Turbo PASCAL and Small C on CP/M. Experimenting with the source of Small C created his interest in compiler technology. Many computers, operating systems, and languages followed these first steps.

Around 2005, he became interested in the D programming language and created the first fun applications in D. Missing a 64-bit D compiler for Windows, he started to contribute to the LLVM compiler framework and LDC, the LLVM-based D compiler. Soon, he became committer of both projects and is now the current maintainer of LDC.

He is also a speaker at the Free and Open Source Software Developers' European Meeting (FOSDEM) and was one of the reviewers of D Cookbook, Packt Publishing.

Writing a book is challenging. I would like to thank everybody who supported me by answering questions, accepting pull requests, or by simply encouraging me to go on. I would also like to thank the reviewers who did a great job. Their comments really contributed to the quality of the book.

About the Reviewers

Orfeo Da Vià is an Italian software developer and has been professionally developing software since 1994. Over the past four years, he has written a number of D software applications.

Orfeo is currently employed as a senior developer at Microline.

Outside the software world, Orfeo enjoys spending time with his two daughters, Raffaella and Adele, and his wife, Alessandra.

Stephan Dilly works as the head of front-end engineering at InnoGames in Germany. In the nine years of professional software development, he has worked in the games industry for Funatics and Ubisoft Blue Byte. He has also worked as a software consultant at Sopra Steria Consulting. The D programming language has been his language of choice for his spare-time projects since 2006. In 2014, Stephan was a speaker at the DConf in San Francisco, where he talked about a backend server architecture developed in D.

Paul Féraud is software engineer with passion for math, algorithms, and programming. He holds a diplôme d'Ingénieur in mechanical engineering from the École Centrale de Nantes in France and a master's degree in software engineering from Keio University in Japan.

Paul has worked for Amadeus, developing a business rule engine that is designed for very high throughput. He has also worked for Dassault Systèmes, developing the architecture backing SIMULIA's finite element simulation systems.

In parallel to this, Paul took great interest in the D programming language and began contributing to its development. He became a member of the core development team and has participated in the design and implementation of its standard library.

Paul now works for Google in Switzerland. He spends most of his time raising his beautiful daughter with his loving and supporting wife.

Kazuki Komatsu is a university student, currently majoring in wireless communication engineering. He started learning D programming language at the age of 16. He has been writing D grammar documents in Japanese and creating a variety of D libraries, such as linear algebra, compile-time meta programming, and Twitter client. Recently, Kazuki has been creating GUI toolkit, awebview, which is similar to GitHub's Electron; however, awebview is written with D and we can write GUI apps with D, HTML, CSS, and JavaScript.

Adam D. Ruppe is the author of D Cookbook, Packt Publishing and a long-time contributor to the D ecosystem.

Robert "burner" Schadek is a regular contributor to the standard D library, Phobos. His D journey started when he used D to create a Distributed Multithreaded Caching D compiler for his computer science master's thesis. He presented this work at DConf 2013. His commitment to Phobos can be seen all over the library. His biggest contribution to Phobos is the experimental logging framework. He is currently working on his PhD in computer science at the University of Oldenburg, Germany. There, he uses the high-performance computing (HPC) facility of the university and a lot of C++ to crunch the numbers on his original data-replication protocol. However, during his programming, he has learned one thing to be true—every untested function is buggy.

www.PacktPub.com

Support files, eBooks, discount offers, and more

For support files and downloads related to your book, please visit www.PacktPub.com.

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at <[email protected]> for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.

https://www2.packtpub.com/books/subscription/packtlib

Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.

Why subscribe?

Fully searchable across every book published by PacktCopy and paste, print, and bookmark contentOn demand and accessible via a web browser

Free access for Packt account holders

If you have an account with Packt at www.PacktPub.com, you can use this to access PacktLib today and view 9 entirely free books. Simply use your login credentials for immediate access.

Preface

In the cloud age, web technologies are more important than ever. The vibe.d framework enables you to use the D programming language for a wide range of web-related tasks. The D programming language allows elegant solutions for common problems, while native compilation produces fast binaries. The vibe.d framework takes advantage of these language features. Together with the innovative use of fibers, the applications that you build are scalable and have a very quick response time.

This book will explain everything you need to know about the vibe.d framework in order to successfully build and run web applications.

What this book covers

Chapter 1, Getting Started with Your First Web Application, explains how to set up and use your development environment. At the end of this chapter, you will have already created your first web application.

Chapter 2, Using Templates for Your Web Pages, covers the Diet template engine. You will learn all about templates—from creating simple static templates to using D code in templates.

Chapter 3, Get Interactive – Forms and Flow Control, brings web forms to your application and introduces route matching.

Chapter 4, Easy Forms with the Web Framework, discusses how to validate user input.

Chapter 5, Accessing a Database, shows how to use a database in an application using a variety of SQL and NoSQL bases.

Chapter 6, Using the REST Interface, teaches you about REST services. You will learn how to provide and consume a generated REST service. You will also study how to interface with an existing REST service.

Chapter 7, The vibe.d Internals, introduces you to the fiber-based pseudo-blocking programming model that is the base for vibe.d.

Chapter 8, Using vibe.d with a GUI Client, applies the vibe.d programming model to a graphical UI application.

Chapter 9, Power Your Application with vibe.d Extensions, shows you what other developers have already implemented with vibe.d and how to publish your application.

What you need for this book

You need a Linux, Windows, or Mac PC that is capable of running the DMD D compiler and the DUB package manager. Both software packages are available at http://code.dlang.org/. The vibe.d framework requires an SSL library and the libevent library to be installed. The various sources are described in Chapter 1, Getting Started with Your First Web Application.

In order to compile the examples, you need an Internet connection in order to allow the automatic download of dependent software.

For the example in Chapter 5, Accessing a Database, you need Redis 3.x (available at http://redis.io/), MongoDB 3.x (available at http://ww.mongodb.org/), and MySQL 5.x (available at http://dev.mysql.com/downloads/). Chapter 6, Using the REST Interface, uses CouchDB (available at http://couchdb.apache.org/) and Chapter 9, Power Your Application with vibe.d Extensions, uses Cassandra (available at http://cassandra.apache.org/).

Who this book is for

Whether you are new to the world of D, already have developed applications in D, or you want to leverage the power of D for web development, then this book is ideal for you. Basic knowledge of core web technologies, such as HTML 5, is helpful; however, it not necessary. This book explains the complex details to speed your web development.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "You also need to install openssl and libevent, which are used by vibe.d."

A block of code is set as follows:

name "hello" description "A simple vibe.d server application." copyright "Copyright © 2015, <yourid>" authors "<yourid>" dependency "vibe-d" version="~>0.7.23" versions "VibeDefaultMain"

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

body block header header Header block navigation include navigation block content block footer footer Footer

Any command-line input or output is written as follows:

$ tar xvzf dub-0.9.24.tar.gz$ cd dub-0.9.24$ ./build.sh

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Click on the Unlock button to unlock the window and change the account type to Administrator."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/8890OS_ColouredImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at <[email protected]> with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.

Chapter 1. Getting Started with Your First Web Application

Today's World Wide Web is shaped by sites, such as Facebook and Amazon, that handle millions of users. The vibe.d framework is designed to create fast and scalable web applications. A significant difference from other frameworks is the use of the D programming language.

In this chapter, you will learn the following:

How to install a D compiler and the DUB package managerWhat the prerequisites of the vibe.d framework areWhat the project structure and files created by the DUB package manager areHow to create a simple web application How to develop with the D programming language

The D programming language is a general purpose programming language that offers modern convenience, modeling power, and native efficiency with a familiar C-style syntax. If you are new to D, then you should visit http://dlang.org/. This site contains the language definition, references to the standard libraries, downloads for the D compiler, and a lot of other tools.

If you have any questions about D, then visit the web forum at http://forum.dlang.org/.

To develop an application in D, all you need is your favorite text editor and the D compiler. The vibe.d framework is used for web applications. You can find information about vibe.d and the programming documentation at http://vibed.org/. For any questions about vibe.d, you can use the web forum at http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/.

The vibe.d framework has some external dependencies, too. It requires the event notification library libevent and the OpenSSL libraries. If you need more information about these libraries, then please visit http://libevent.org/ and https://openssl.org/.

The following section describes how to install the D compiler, package manager DUB, and dependencies on your operating system.

Installing the D compiler and the DUB package manager

The vibe.d framework is written in the D programming language. To get started, you need a D compiler and the DUB package manager. You also need to install openssl and libevent, which are used by vibe.d.

There are three major D compilers available, as follows:

The reference compiler, DMD (http://dlang.org/download.html)The GNU compiler, GDC (http://gdcproject.org/downloads)The LLVM-based compiler, LDC (https://github.com/ldc-developers/ldc/releases)

You can use any of these compilers to develop with the vibe.d framework. However, the installation instructions are very different. In this book, only the DMD compiler is used.

A recommended setup is to use the DMD compiler during development and one of the other compilers to produce the final highly optimized binary.

Ubuntu and Debian

The easiest way to install DMD on Ubuntu and Debian is to use the D APT repository provided by Jordi Sayol. The website of this project is located at http://d-apt.sourceforge.net/. The steps to install DMD and DUB are as follows:

Open a terminal and type the following in order to add the repository sources:
$ sudo wget http://master.dl.sourceforge.net/project/d-apt/files/d-apt.list -O /etc/apt/sources.list.d/d-apt.list
Then, you need to update the list of packages:
$ sudo apt-get update

This command complains that the public key for the d-apt repository could not be verified. The displayed fingerprint is EBCF975E5BA24D5E. Allow an unauthenticated install of d-apt and update the list of packages again:

$ sudo apt-get -y --allow-unauthenticated install --reinstall d-apt-keyring$ sudo apt-get update
Now you are ready to install the compiler and the package manager:
$ sudo apt-get install -y dmd-bin$ sudo apt-get install -y dub
Lastly, you need to install openssl and libevent:
$ sudo apt-get install -y libssl-dev libevent-dev

Fedora

On Fedora, you use the pre-built compiler binary from thedlang.org website. There is no package for the DUB package manager therefore, you must built this tool from the source. Refer to http://dlang.org/download.html and download the Fedora package of the DMD compiler. The available version at the time of writing this book is 2.068.2. You may need to change the version number when a new version of the compiler is released. The instructions are given for Fedora 22 or later. If you use Fedora 21 or earlier, then replace the dnf command with yum. The steps to install the DMD complier are as follows:

To install dmd, type in a terminal:
$ sudo dnf install –y dmd-2.068.2-0.fedora.x86_64.rpm
Install the required openssl and libevent libraries. You also need to install the development package of libcurl that is used to compile dub:
$ sudo dnf install –y openssl-devel libevent-devel libcurl-devel
After that, go to http://code.dlang.org/download and download source tarball of DUB. The current version number is 0.9.24. Again, you need to change the version number if a newer version is available. To compile and install, just type the following:
$ tar xvzf dub-0.9.24.tar.gz$ cd dub-0.9.24$ ./build.sh$ sudo cp bin/dub /usr/local/bin

Tip

If you get an error message that you are not in the list of sudoers, then you need to change the type of your user to administrator. Open system settings and click on Users. Click on the Unlock button to unlock the window and change the account type to Administrator. Now you can use the sudo command.

OS X

To install the D compiler and the DUB package manager, you can use the Homebrew package manager (http://brew.sh/):

Open a terminal and first update the formulae:
$ brew update
Now install the D compiler:
$ brew install dmd
Next, you will install the DUB package manger:
$ brew install dub
Lastly, you need to install openssl and libevent:
$ brew install openssl libevent

Windows

On Windows, you will simply use the pre-built binaries from the dlang.org website. Go to http://dlang.org/download.html and download the Windows EXE file of the DMD compiler. Double-click on the downloaded file in order to start the installer and then follow the instructions on the screen. The D compiler is now ready to use.

DUB is installed in a similar way. Go to http://code.dlang.org/download and download the installer for Windows. Double-click on the downloaded file to start the installer and then follow the instructions on the screen as done previously.

Building from source

You can also build the applications from source. For some systems, (for example, FreeBSD, Solaris x86, and Linux on non-Intel platforms) this is the only way to install the software. The following are the instructions for a Portable Operating System Interface (POSIX) for a Unix system.

At the time when this book was written, the compiler itself was translated from C++ to D. Version 2.068 is the first one that requires a D compiler for bootstrap. Therefore, you need to install version 2.067.1 before you can install the current version of the compiler.

At build time, you need the GNU C/C++ compiler (gcc/g++) and GNU make (gmake). Using another compiler or make tool may work but is not well tested. For Phobos (the D standard library), you need to have libcurl installed. If your distribution does not provide libcurl