From 82742d5d13dc7b0691a79c79f8e62782fcb16e10 Mon Sep 17 00:00:00 2001
From: justanothercatgirl This is a link shortener. A sort of a backend practice, but it should run 24/7/53/<While I pay for my VPS> after I finish writing it. All documentation assumes that the server is running server.com on port 80 without https, and you are trying to shorten a link to example.com. All (non-global) parameters are mandatory, unless marked with question mark ? sign. PATH means part in url after the first slash: e.g. in link http://server.com/short, "short" is PATH, while URL means full shortened link. The API follows this convention: everything is done through GET requests, client supplies all necessary parameters in URLencoded format.
+ Whatever server returns depends on parameters; it may be application/json (for programmable API) OR text/html (to render in HTML) Example request: http://ln.twistea.su/api/linkadd?url=https%3A%2F%2Fexample.com&format=html. Note: server may return json string like null or true: according to
+ rfc-8259, this is valid json and clients have to handle this accordingly. Errors are returned like this: {"error": description} (some endpoints may return null / false to indicate failure).
+ Description may be any of the following: What is this?
+ Documentation conventions
+ API reference
+
+ This request may return something like: <a href="http://server.com/DEADF00D">your link: DEADF00D</a>
+
Plese note that the HTTP return status for malformed request may be BAD_REQUEST (400) or INTERNAL_SERVER_ERROR (500)
Key | +Value | +Description | +Default | +
---|---|---|---|
format | +json | html | +How to return the result of request. html should only be used to embed it in a web page. | +json | +
Endpoint | +Parameters | +Response object | +|
---|---|---|---|
key | +value | +||
/api/linkadd | +url | +string: a link to be shortened | +{"url": "https://server.com/PATH"} | error + | +
try? | +string: PATH to try to put link under + (if not occupied, WITHOUT https://server.com/) |
+ ||
/api/linkdel | +path | +string: PATH to delete the link from | +true | false | +
/api/linkget | +path | +string: PATH to get link info from | +{"url": "original url", created: int unix_timestamp} + OR null + |
+
/PATH | +Returns an HTML page with redirection message and returns 302 (HTTP_FOUND), with + Location header set to shortened URL | +/getargs | +Get an HTML page with a list of all parameters provided to the endpoint. Used for testing. | + + + +
This section is unfinished.
+ + diff --git a/www/form.html b/www/form.html new file mode 100644 index 0000000..79eb7b1 --- /dev/null +++ b/www/form.html @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/www/index.html b/www/index.html new file mode 100644 index 0000000..a2af744 --- /dev/null +++ b/www/index.html @@ -0,0 +1,32 @@ + + + + +Try it out!
+ +