briefly.public

command module
v0.0.0-...-8167bb2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

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>.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cli
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL