From c4096b4a1d587c032f64405c03156aaa41fb5bb3 Mon Sep 17 00:00:00 2001 From: garritfra Date: Sat, 22 Dec 2018 16:27:13 +0100 Subject: [PATCH] Add --port flag --- README.md | 2 +- main.go | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 113a393..f3533a7 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,4 @@ The REST API currently exposes these Endpoints: | GET | /mine_block | Mine a block with all pending transactions | | GET | /is_valid | Check, if the chain has any faulty blocks | -Refer to the [wiki](https://github.com/garritfra/blockchain-project/wiki) to get more information about the REST API +Refer to the [wiki](https://github.com/garritfra/blockchain-project/wiki) to get more information about the REST API \ No newline at end of file diff --git a/main.go b/main.go index 8b8784c..5fe0094 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,20 @@ package main import ( + "flag" + "fmt" + "strconv" + "github.com/garritfra/blockchain-project/server" ) func main() { - server.ServeHTTP(":42000") + portFlag := flag.Int("port", 42000, "The port this service is running on") + flag.Parse() + + var port string + port += ":" + port += strconv.Itoa(*portFlag) + fmt.Println(*portFlag) + server.ServeHTTP(port) }