Giter Site home page Giter Site logo

url-shortener's Introduction

url-shortener

Simple URL shortener service written in ASPNET Core 2.0. Using Postgresql

Endpoints

POST /: with body parameter:

{
    "url": "URL"
}

where URl is the url that needs to be redirected to. The reponse of the output have content type application/json and returns:

{
    id: GUID,
    shortId: string
}

GET /<id | shortId>: where it can be either id or shortId. This redirects to the page (if it exists) or redirects to a default page (RedirectUrl). If RedirectUrl is empty it will throw a 404.

Settings

In appsettings there are following settings for the url shortener

  • Domains: Domains allowed to be shorten. Multiple domains are separated with comma (,) (example default.com, default2.(com|net))
  • ShortIdCharacters: The characters allowed for the shortId (case sensitive).
  • ShortIdLength: The length of the shortId.
  • RedirectUrl: The default page to redirect to if the url is missing from the database (if empty it just throws 404 page).

The ConnectionString needs to be a Postgresql connection string.

Database

The database have 3 tables. Urls: Containing the url, shortId, Id and date. UrlRedirects: Containing analytics on how often the urls have been used and when. UrlErrors: Containing errors in form of not found urls, short id generation errors, wrong domains.

Both MSSQL and PostgreSQL are allowed. Just add the settings to the appsettings within DataSettings:

MSSQL "MSSQLConnectionString": "Data Source=tcp:localhost,1433;Database=UrlShorten;User ID=admin;Password=password;MultipleActiveResultSets=True"

PostgreSQL "PostgresConnectionString": "User ID=postgres;Password=password;Host=localhost;Port=5432;Database=UrlShortener;Pooling=true;"

url-shortener's People

Contributors

madslundt avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.