Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Opa Application Development

You're reading from   Opa Application Development A rapid and secure web development framework to develop web applications quickly and easily in Opa

Arrow left icon
Product type Paperback
Published in Jun 2013
Publisher Packt
ISBN-13 9781782163749
Length 116 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Li Wenbo Li Wenbo
Author Profile Icon Li Wenbo
Li Wenbo
Arrow right icon
View More author details
Toc

Dispatching requests


We have gone through the first two cases of Server.handler. They are both simple and accept all requests. But in real web applications, requests and responses are much more complicated, and the web server should respond differently according to different requests. This section we will cover the remaining cases of Server.handler and will show how to handle different types of requests.

The resource handler

A resource handler is often used to serve static resources such as images and sounds. The case {stringmap(resource) resources} performs on a non-decoded URI (Uniform Resource Identifier), and returns a resource that the URI matches with the resource's stringmap. To make it clear, let's suppose there are three images in the directory res: opa1.png, opa2.png, and opa3.png.

If we create the resources stringmap manually, it should look like this:

"res/opa1.png" -> a resource of opa1.png
"res/opa2.png" -> a resource of opa2.png
"res/opa3.png" -> a resource of opa3.png...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image