add readme
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
# Ultrashorty
|
||||||
|
|
||||||
|
Really simple HTTP redirection using a CSV file.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Create a CSV file with the following headings and add in as many redirects as you like:
|
||||||
|
|
||||||
|
```csv
|
||||||
|
From,To,Status Code
|
||||||
|
```
|
||||||
|
|
||||||
|
Start Ultrashorty:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ultrashorty /path/to/redirects.csv
|
||||||
|
```
|
||||||
|
|
||||||
|
To load changes to the CSV, just stop and restart Ultrashorty.
|
||||||
+2
-2
@@ -2,6 +2,6 @@ package internal
|
|||||||
|
|
||||||
type CLI struct {
|
type CLI struct {
|
||||||
File string `arg:"" name:"file" short:"f" help:"Path to CSV redirects file." type:"path"`
|
File string `arg:"" name:"file" short:"f" help:"Path to CSV redirects file." type:"path"`
|
||||||
Host string `name:"host" help:"HTTP listen host." default:"${host}"`
|
Host string `name:"host" help:"HTTP listen host." default:"localhost"`
|
||||||
Port string `name:"port" short:"p" help:"HTTP listen port." default:"${port}"`
|
Port string `name:"port" short:"p" help:"HTTP listen port." default:"4000"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ func ReadCsvRedirects(file string) (Redirects, error) {
|
|||||||
return nil, errors.New("CSV must contain From, To, and Status Code headings")
|
return nil, errors.New("CSV must contain From, To, and Status Code headings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read data
|
||||||
redirects := Redirects{}
|
redirects := Redirects{}
|
||||||
|
|
||||||
for {
|
for {
|
||||||
row, err := csvReader.Read()
|
row, err := csvReader.Read()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -10,13 +10,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
vars := kong.Vars{
|
|
||||||
"host": "localhost",
|
|
||||||
"port": "4000",
|
|
||||||
}
|
|
||||||
|
|
||||||
cli := &internal.CLI{}
|
cli := &internal.CLI{}
|
||||||
kong.Parse(cli, vars)
|
kong.Parse(cli, kong.Name("ultrashorty"), kong.Description("Really simple HTTP redirection using a CSV file."))
|
||||||
|
|
||||||
redirects, err := internal.ReadCsvRedirects(cli.File)
|
redirects, err := internal.ReadCsvRedirects(cli.File)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user