diff --git a/assets/index.html b/assets/index.html index c7ca6b1..8ff515b 100644 --- a/assets/index.html +++ b/assets/index.html @@ -13,7 +13,7 @@ tinyurl.com. qurl.org is open source, it's code is freely available - and has an easy to use API. + and has an easy to use API.
diff --git a/assets/usage.html b/assets/usage.html new file mode 100644 index 0000000..423b935 --- /dev/null +++ b/assets/usage.html @@ -0,0 +1,47 @@ + + + + + qurl.org - API usage + + + +

API usage

+ +

API URL: http://qurl.org/api/url

+

+

+

+ +

+

+

+ +

API example

+

+ 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"]))