Giter VIP home page Giter VIP logo

briefly.public's Introduction

Briefly.public

Introduction

This repository is part of the project briefly. Briefly project is a URL shortcoder.

This repository concern the REST service to expose with gin-tonic golang library

Endpoints

shortcode URL

POST method: /shortcoder

Body content

POST json body:

{"url": "http://www.google.fr"}

Return reponse

GET a id of the URL in return HTTP code 200

unshortcode URL

GET method: /unshortcoder/:hash

Path parameter

hash: id of the URL

Return reponse

A redirect HTTP code 301 with the unshortcoded URL associated to the path parameter hash

Compilation

Mage compilation

Pre-requisite

Please install mage

Dependancies / Generate artifact

$ mage

An artifact named 'briefly.public' is generated in './bin/' folder

Usage

Pre-requisite

The briefly gRPC server have to run to execute the backend work.

Please clone and follow documentation of briefly gRPC, to have a running gRPC server.

Generate configuration file

$ ./bin/briefly.public config new

will generate a default configuration file

###############################
# Briefly.public Settings 
###############################
[Briefly_public]

  ###############################
  # Briefly gRPC API settings 
  ###############################
  [Briefly_public.Briefly]

    # URL and Port for the Briefly gRPC server
    adress = "localhost:5556"

  ###############################
  # REST API settings 
  ###############################
  [Briefly_public.REST]

    # On which port REST HTTP service will listen
    listenPort = ":8080"

###############################
# Logs Settings 
###############################
[Log]

  # Allow to display logs in Json format if true
  jsonformatter = false

  # Log level: trace, debug, info, warning, error, panic, and fatal
  level = "warning"

store it as toml file in example in 'conf' folder onto './conf/briefly.public.conf.toml' file

Run HTTP server

$ ./bin/briefly.public startHttp --config ./conf/briefly.public.conf.toml

Call endpoints

shortcode URL endpoint

$ curl -X POST  http://127.0.0.1:8080/shortcoder/ -H 'content-type: application/json' -d '{ "url": "https://www.google.com" }'
2073697506084

unshortcode URL endpoint

$ curl 127.0.0.1:8080/unshortcoder/2073697506084 
<a href="https://www.google.com">Moved Permanently</a>.

briefly.public's People

Contributors

francois-poidevin avatar

Watchers

 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.