Skip to content

francois-poidevin/briefly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Briefly

Introduction

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

This repository concern the gRPC server to generate ID of a received URL and a answer an URL link to an ID (previously associated to an ID)

Compilation

Protobuf

Prototool (UBER)

Prototool is neccessary to generate protobuf

Info: Into the pipeline to migrate to buf

Installation
$ GO111MODULE=on go get github.com/uber/prototool/cmd/prototool@dev

Mage compilation

Pre-requisite

Please install mage

Dependancies / Generate artifact

$ mage

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

Usage

Generate

$ ./bin/briefly config new

will generate a default configuration file

###############################
# Briefly Settings 
###############################
[Briefly]

  ###############################
  # GRPC API settings 
  ###############################
  [Briefly.GRPC]

    # On which port REST HTTP service will listen
    listenPort = 5556

###############################
# 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.conf.toml' file

Run server

$ ./bin/briefly startGrpc --config ./conf/briefly.conf.toml

Call endpoints

GetShortCodeHash endpoint

$ prototool grpc --address localhost:5556 --method briefly.schema.v1.SchemaAPI/GetShortCodeHash --data '{"url":"test"}'
{"hash":"13606376228"}

GetShortCodeHash endpoint

$ prototool grpc --address localhost:5556 --method briefly.schema.v1.SchemaAPI/GetUnShortCodedURL --data '{"hash":"test"}'
{"url":"https://www.google.com"}