Skip to content

Commit

Permalink
Reintroduce curl example with localhost
Browse files Browse the repository at this point in the history
  • Loading branch information
kubilaykarpat committed May 14, 2024
1 parent 59db0b3 commit 235fb81
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/myhttpclient/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type GetPatientResponse struct {

func (cl *Client) GetClientOnUid(patientUid string) (*GetPatientResponse, error) {
client := http.Client{Timeout: cl.timeout}
httpResponse, err := client.Get(fmt.Sprintf("https://gotrainingxebia.appspot.com/api/patient/%s", patientUid))
httpResponse, err := client.Get(fmt.Sprintf("http://localhost:8080/api/patient/%s", patientUid))
if err != nil {
return nil, fmt.Errorf("Error fetching patient: %s", err)
}
Expand Down
12 changes: 10 additions & 2 deletions go-training.slide
Original file line number Diff line number Diff line change
Expand Up @@ -2023,9 +2023,17 @@ Example with "Alice"
* Exercise: http server

- Create a HTTP server that supports POST on /api/patient to create a patient
- Test it with your previously created HTTP-client
- Create a unit test in which you simulate client behavior (using httptest-package)
- Test it with curl or your previously created HTTP-client

# Example curl request to submit a new patient
curl -vvv \
-X POST \
--data '{"uid":"1", "fullName":"Marc","addressLine":"a","allergies":["peanut"]}' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
http://localhost:8080/api/patient

- Create a unit test in which you simulate client behavior (using httptest-package)

#----------------------------------------------
* Tooling
Expand Down

0 comments on commit 235fb81

Please sign in to comment.