hurl

Version, currently master branch1 version
  • master branchlatestAug 23, 2017

github.com/z64/hURL

a link shortener

2 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  hurl:
    github: z64/hURL
    branch: master

master is a branch, not a release, so this tracks it rather than pinning a version.

Then run:

shards install

shard.yml

Crystal
0.23.1
License
MIT
Author
Zac Nowicki
Target
  • hurl from src/hurl.cr

Dependencies

Runtime Dependencies

  • raze*github: samueleaton/raze
  • redis*github: stefanwille/crystal-redis

README

hURL

It's a link shortener thing.

Deployment

hURL supports deployment with docker and docker-compose.

It should be as simple as cloning this repo and running docker-compose up -d.

This will create containers of a compiled hURL image networked with a Redis instance.

By default, it listens on port 7777. See the docker-compose.yml for more information.

API

POST / - Create a redirect

Returns the created redirect object.

JSON Body

keytyperequired
targetURI stringyes
codestringno
ttlintegerno
  • target must be HTTPS scheme and the host must respond to a HEAD request, replying with an 200 OK status code.
  • code must not already be taken. If omitted, one will be generated.
  • code length must not be longer than the compiled MAX_CODE_LENGTH.
  • ttl must be within the compiled MIN_TTL and MAX_TTL. If omitted, a default will be provided.

JSON Body Example

{
  "target": "https://github.com/z64/hURL",
  "code": "hurl",
  "ttl": 120
}

The redirect will live at localhost:7777/hurl until it expires.

GET /{code} - Query redirect

Executes a redirect stored at the given code to its target.

If you provide the header Accept: application/json, you will get the stored object instead of being redirected.

Note: If using Redis, viewing the redirect object counts as a use.

Client

An (extremely simple) client is provided too for your crystal apps to talk to a hURL service.

Usage

require "hurl/client"

client = Hurl::Client.new("http://hrl.zsixtyfour.com")

client.create("https://github.com/z64/hURL", code: "hurl")
#=> Link

link = client.get("hurl")
#=> Link

Contributors

  • z64 Zac Nowicki - creator, maintainer