From 0216358dfb2d7ad7483ce1357f880c0e2d8a60dd Mon Sep 17 00:00:00 2001
From: cdramey
+
+ Submit:
http://qurl.org/api/url?url=http://fark.com+ Response:
{"exists":true,"url":"http:\/\/qurl.org\/s"}
+
+ + Submit:
http://qurl.org/api/url?url=http://klasjdlh.com+ Response:
{"exists":false,"url":"http:\/\/qurl.org\/Z1q"}
+
+ + Submit:
http://qurl.org/api/url?url=notaurl+ Response:
{"error":"Not a valid URL."}
+
+
+
diff --git a/pages/root.go b/pages/root.go
index 062ad6f..e3e82aa 100644
--- a/pages/root.go
+++ b/pages/root.go
@@ -15,6 +15,7 @@ type RootHandler struct {
index *static.StaticContent
css *static.StaticContent
favi *static.StaticContent
+ usage *static.StaticContent
submit *template.Template
}
@@ -36,6 +37,9 @@ func (ctx *RootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
case "/favicon.ico":
ctx.favi.ServeHTTP(w, r)
+ case "/api/usage.html":
+ ctx.usage.ServeHTTP(w, r)
+
case "/api/url":
ctx.ServeAPI(w, r)
@@ -73,7 +77,7 @@ func (ctx *RootHandler) Init() error {
}
ctx.css = css
- // Initialize the static content object for the css
+ // Initialize the static content object favicon
favi := &static.StaticContent{Content: "favicon.ico"}
err = favi.Init()
if err != nil {
@@ -81,6 +85,14 @@ func (ctx *RootHandler) Init() error {
}
ctx.favi = favi
+ // Initialize the api usage instructions
+ usage := &static.StaticContent{Content: "usage.html"}
+ err = usage.Init()
+ if err != nil {
+ return err
+ }
+ ctx.usage = usage
+
// Initialize submit page template
ctx.submit = template.New("submit.html")
_, err = ctx.submit.Parse(string(static.Assets["submit.html"]))