diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml new file mode 100644 index 0000000..ca3d8b8 --- /dev/null +++ b/.gitea/workflows/build.yaml @@ -0,0 +1,24 @@ +name: Build bang-server +run-name: ${{ gitea.actor }} is building bang-server +on: [push] + +jobs: + Explore-Gitea-Actions: + runs-on: ubuntu-latest + steps: + - run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event." + - run: echo "This job is now running on a ${{ runner.os }} server" + - run: echo "Branch is ${{ gitea.ref }} and repository is ${{ gitea.repository }}." + - name: Check out repository code + uses: actions/checkout@v4 + - run: echo "${{ gitea.repository }} repository has been cloned to the runner." + - run: echo "The workflow is now ready to test your code on the runner." + - name: Setup Go + uses: actions/setup-go@v3 + with: + go-version: '1.24.4' + - name: Build the server app + run: go build bang.go + - name: List files + run: ls -lh + - run: echo "This job's status is ${{ job.status }}." \ No newline at end of file diff --git a/.gitignore b/.gitignore index 106c786..edebcad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ /mailboxes/ -users.json \ No newline at end of file +users.json +bang.exe +testclient.py \ No newline at end of file diff --git a/bang.go b/bang.go index 5124d40..502280c 100644 --- a/bang.go +++ b/bang.go @@ -5,6 +5,7 @@ import ( "crypto/sha256" "encoding/base64" "encoding/json" + "flag" "fmt" "io" "io/ioutil" @@ -329,10 +330,13 @@ func withCORS(handler http.HandlerFunc) http.HandlerFunc { } func main() { + port := flag.Int("port", 8080, "port to listen on") + flag.Parse() + http.HandleFunc("/users", withCORS(createUserHandler)) http.HandleFunc("/email", withCORS(receiveEmailHandler)) http.HandleFunc("/mailbox", withCORS(listMailboxHandler)) http.HandleFunc("/mailbox/open", withCORS(markEmailOpenedHandler)) - log.Println("Email server running on :80") - log.Fatal(http.ListenAndServe(":80", nil)) + log.Printf("Email server running on :%d", *port) + log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil)) }