shortner

command module
v0.0.0-...-acd44cb Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 1 Imported by: 0

README

shortner CircleCI Build Status Go Report Card MIT Licensed

Installation

  • Go 1.12
    $ wget https://dl.google.com/go/go1.12.9.linux-amd64.tar.gz
    $ sudo tar -C /usr/local -xzf go1.12.9.linux-amd64.tar.gz
    $ mkdir $HOME/go
    $ export PATH=$PATH:/usr/local/go/bin
    $ export GOPATH=$HOME/go
    $ go get github.com/go-sql-driver/mysql
    $ go get github.com/jmoiron/sqlx
    $ go get github.com/rs/cors
    $ go get gopkg.in/yaml.v2
    
  • Git
    $ sudo apt-get install git
    $ mkdir $HOME/code
    $ cd $HOME/code
    $ git clone https://github.com/donh/shortner.git
    $ cd $HOME/code/shortner
    
  • MySQL
    $ sudo apt-get install mysql-server
    $ mysql -h 127.0.0.1 -P 3306 -u root -p < ./scripts/tree.sql
    

Lint

  • Go
    $ go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
    
    $ golangci-lint run --fix
    

Build

$ go build -i -v ./...

Run

$ go run ./main.go

API

  • API list
    • /api/v1/add
    • /{key}
API Example
  • /api/v1/add
    • Add a shorten URL
    • method
      • POST
    • Request
    POST http://localhost:8000/api/v1/add
    
    {
      "url": "https://github.com/donh/shortner"
    }
    
    • Response
    {
      "Result": "http://localhost:8000/1g3e",
      "Status": 200,
      "Error": "",
      "Time": "2019-08-16 16:36:24"
    }
    
  • /{key}
    • Redirect to original URL
    • method
      • GET
    • Request
    GET http://localhost:8000/1g3e
    

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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