Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datetime client #1

Merged
merged 30 commits into from
Jan 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0fdc417
feat: simple http client
RawanMostafa08 Sep 17, 2024
fc70fe4
fix: edit file structure
RawanMostafa08 Sep 17, 2024
06f3554
fix: edit project structure and code organization
RawanMostafa08 Sep 18, 2024
98c792a
fix: project structure
RawanMostafa08 Sep 18, 2024
dab676c
feat: Adding configurable url,port,endpoint using flags
RawanMostafa08 Sep 18, 2024
e007cde
feat: add env var configurations
RawanMostafa08 Sep 19, 2024
8f3d9f3
fix: edit code organization and dependencies
RawanMostafa08 Sep 19, 2024
6ec3abd
test: sendRequest test
RawanMostafa08 Sep 19, 2024
9c3cc7e
feat: retry mechanism using backoff
RawanMostafa08 Sep 20, 2024
995f1a5
feat: Testing the client using a mock server
RawanMostafa08 Sep 20, 2024
5e8fef3
feat: logging using slog
RawanMostafa08 Sep 20, 2024
aaf1821
fix : time format
RawanMostafa08 Sep 20, 2024
aad0fb1
doc: API documentation for client functions
RawanMostafa08 Sep 21, 2024
b2eb27e
doc: User documentation
RawanMostafa08 Sep 21, 2024
9c36bc0
trial commit
RawanMostafa08 Sep 21, 2024
8677d13
chore: pulling the docker image
RawanMostafa08 Sep 22, 2024
7c7aa45
chore: making the processes background processes
RawanMostafa08 Sep 22, 2024
bd41c6c
fix: edit testcases baseUrl
RawanMostafa08 Sep 22, 2024
7bb2149
fix: edit docker running command
RawanMostafa08 Sep 22, 2024
e61a479
fix: edit test urls
RawanMostafa08 Sep 22, 2024
775c973
fix: edit test urls
RawanMostafa08 Sep 22, 2024
5370b1d
chore: fix github workflow
RawanMostafa08 Sep 22, 2024
d5b4fd2
fix: code dependencies, making GetTime() return time and error and is…
RawanMostafa08 Sep 22, 2024
b263040
test: fixing the tests after applying the dependency edits
RawanMostafa08 Sep 22, 2024
010f502
doc: fix the repo cloning link
RawanMostafa08 Sep 23, 2024
3b426fa
doc: matching the user socumentation with the new code dependency cha…
RawanMostafa08 Sep 23, 2024
843870c
chore: removing running on pull request
RawanMostafa08 Sep 23, 2024
21463a1
fix: applying review comments: changing decideConfigs to loadConfigs,…
RawanMostafa08 Oct 1, 2024
c68bf12
fix: edit test so that mock server creation is in a separate helper f…
RawanMostafa08 Oct 1, 2024
1eaf3f3
fix: review comment: increasing the MaxElapsedTime for retrial
RawanMostafa08 Oct 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Adding configurable url,port,endpoint using flags
RawanMostafa08 committed Sep 18, 2024
commit dab676cd8f624e9251854a3ecc13523b9c8db6fe
16 changes: 15 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
package main

import (
"flag"
"fmt"
"log"

pkg "github.com/codescalersinternships/Datetime-client-RawanMostafa/pkg"
)

func main() {

var port int
flag.IntVar(&port, "port", 0, "Specifies the port")

var url string
flag.StringVar(&url, "url", "", "Specifies the base url")

var endpoint string
flag.StringVar(&endpoint, "endpoint", "", "Specifies the endpoint")

flag.Parse()

c := pkg.CreateClient()
resp, err := pkg.SendRequest(c, "8080")
resp, err := pkg.SendRequest(c, url, endpoint, fmt.Sprint(port))
if err != nil {
log.Fatal(err)
}
4 changes: 2 additions & 2 deletions pkg/callers.go
Original file line number Diff line number Diff line change
@@ -21,8 +21,8 @@ func ReadBody(resp *http.Response) (string, error) {
return string(body), nil
}

func SendRequest(c http.Client, port string) (*http.Response, error) {
resp, err := c.Get("http://localhost:" + port + "/datetime")
func SendRequest(c http.Client, baseUrl string, endpoint string, port string) (*http.Response, error) {
resp, err := c.Get(baseUrl + ":" + port + endpoint)
if err != nil {
return nil, fmt.Errorf("error in sending request: %v", err)
}