Skip to content

thekid/shorturl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShortURL

Build status on GitHub Uses XP Framework BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Less than 1000 lines

URL Shortener service

Setup

Create a database:

create database HUDDLE
use HUDDLE
create table url (id varchar(40) not null PRIMARY KEY, value varchar(1024))
grant all on HUDDLE.* to 'huddle'@'%' identified by '...'

Run composer:

$ composer install
# ...

Running

Start the server:

$ export HUDDLE_PASS=...
$ xp -supervise web -c src/main/etc/prod de.thekid.shorturl.Api

Working with the service

Create a URL:

$ curl -i localhost:8080 -d "url=https://github.com/"
HTTP/1.1 201
Date: Sun, 14 Aug 2016 10:25:39 GMT
Location: /d7b3438

Access the URL:

$ curl -i localhost:8080/d7b3438
HTTP/1.1 302
Date: Sun, 14 Aug 2016 10:26:17 GMT
Location: https://github.com/

Create a named URL:

$ curl -i localhost:8080 -d "url=http://thekid.de/&name=home"
HTTP/1.1 201
Date: Sun, 14 Aug 2016 10:25:39 GMT
Location: /home

Administering the service

List URLs:

$ curl -i admin:$HUDDLE_PASS@localhost:8080
HTTP/1.1 200
Date: Sun, 14 Aug 2016 10:39:42 GMT
Content-Type: application/json

[{"id":"d7b3438","value":"https://github.com/"},{"id":"home","value":"http://thekid.de/"}]

Delete URLs:

$ curl -i -X DELETE admin:$HUDDLE_PASS@localhost:8080/d7b3438
HTTP/1.1 204
Date: Sun, 14 Aug 2016 10:38:26 GMT

Releases

No releases published

Packages

No packages published

Languages