Explorar o código

update documentation, add license

Aneurin Barker Snook hai 1 ano
pai
achega
cc6b439b34
Modificáronse 3 ficheiros con 38 adicións e 3 borrados
  1. 9 0
      LICENSE.md
  2. 26 0
      README.md
  3. 3 3
      main.go

+ 9 - 0
LICENSE.md

@@ -0,0 +1,9 @@
+# License
+
+Copyright (c) Recipeer - all rights reserved.
+
+Unauthorized copying of this file or any other file in this repository is strictly prohibited.
+
+Proprietary and confidential.
+
+Aneurin Barker Snook <aneurin@recipeer.co.uk>, November 2023

+ 26 - 0
README.md

@@ -1 +1,27 @@
 # Short URL Service
+
+A simple, static redirection service that redirects recognised paths to any other URL.
+
+## Configuration
+
+Set environment variables:
+
+- `HOST` and `PORT` configure the HTTP listen server
+- `CSV` contains redirection data in CSV format
+
+Environment variables can be set in the environment or a `.env` file.
+
+> :warning: CSV data **is not** loaded from a file!
+
+## Redirection data CSV
+
+The CSV data must have two columns for the path and redirection URL, respectively. The first row is reserved for headings. Follow this example to get started:
+
+```
+path,url
+/some/path,https://some-url.com
+```
+
+## License
+
+See [LICENSE.md](./LICENSE.md)

+ 3 - 3
main.go

@@ -14,7 +14,7 @@ import (
 	"github.com/spf13/viper"
 )
 
-// ListenHTTP starts an HTTP server that redirects any request for a recognised path to the appropriate URL.
+// ListenHTTP starts an HTTP server that redirects any request for a recognised path to the corresponding URL.
 // The server address and port can be configured with HOST and PORT environment variables, respectively.
 // The default port is 3000.
 func ListenHTTP(config *viper.Viper, redirects map[string]string) <-chan error {
@@ -45,9 +45,9 @@ func ListenHTTP(config *viper.Viper, redirects map[string]string) <-chan error {
 // The CSV data must be in the format:
 //
 //	path,url
-//	/some/path,https://some-url.com/...
+//	/some/path,https://some-url.com
 //
-// The first line is always skipped, allowing for headers.
+// The first line is always skipped, allowing for CSV headings.
 func ReadRedirects(config *viper.Viper) (map[string]string, error) {
 	data := config.GetString("csv")
 	if data == "" {