Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add a default view, handle incomplete domain names

  • Loading branch information...
commit f7acb369d7661be9010557b9b531ad390e99552d 1 parent 311968c
Joël Franusic authored December 26, 2009
13  jsondns.rb
... ...
@@ -1,13 +1,16 @@
1 1
 require 'dnsruby-jsonquery'
2 2
 require 'sinatra'
3 3
 
4  
-indomain = 'example.com'
5  
-intype = 'A'
  4
+resolver = Dnsruby::Resolver.new({:nameserver => "8.8.8.8"}) # Google DNS
6 5
 
7  
-res = Dnsruby::Resolver.new({:nameserver => "8.8.8.8"}) # Google DNS
  6
+get '/' do
  7
+  erb :index
  8
+end
8 9
 
9 10
 get '/IN/:domain/:type' do
10  
-  res.jsonquery(params[:domain],params[:type])
  11
+  resolver.jsonquery(params[:domain],params[:type])
11 12
 end
12 13
 
13  
-
  14
+get '/IN*' do
  15
+  resolver.jsonquery(nil,nil)
  16
+end
22  views/index.erb
... ...
@@ -0,0 +1,22 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
  2
+"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
  3
+<html xmlns="http://www.w3.org/1999/xhtml">
  4
+<head>
  5
+<title>jsondns</title>
  6
+<meta name="description" content="Make DNS queries via REST." />
  7
+<meta name="keywords" content="json,dns" />
  8
+<meta name="author" content="Joel Franusic" />
  9
+
  10
+<!-- Favicon -->
  11
+<link rel="shortcut icon" href="" />
  12
+
  13
+</head>
  14
+
  15
+<body>
  16
+
  17
+<div id="container">
  18
+Try <a href="/IN/google.com/A">this</a>.
  19
+</div><!-- container -->
  20
+
  21
+</body>
  22
+</html>

0 notes on commit f7acb36

Please sign in to comment.
Something went wrong with that request. Please try again.