Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: bozd4g/go-http-client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.1.4
Choose a base ref
...
head repository: bozd4g/go-http-client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 22, 2022

  1. Update go version

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    3554d00 View commit details
  2. Update codecov yaml

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    d977e02 View commit details
  3. Remove types.go

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    0e0ad58 View commit details
  4. Add option.go

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    b9aea12 View commit details
  5. Add response.go

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    6b01d2b View commit details
  6. Modify client and remove tests

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    036e793 View commit details
  7. Add example.go

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    628bb8a View commit details
  8. Add get func into response

    bozd4g committed Oct 22, 2022
    Copy the full SHA
    a6d11a9 View commit details

Commits on Oct 31, 2022

  1. Edit new request func with ctx

    bozd4g committed Oct 31, 2022
    Copy the full SHA
    df081ad View commit details
  2. Add new tests

    bozd4g committed Oct 31, 2022
    Copy the full SHA
    1b05b6c View commit details

Commits on Nov 5, 2022

  1. Add makefile

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    5a97655 View commit details
  2. Add new test case

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    dc716af View commit details
  3. Update gitignore

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    fd00873 View commit details
  4. Copy the full SHA
    bb9be2b View commit details
  5. Update client and their tests

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    f6ac65b View commit details
  6. Update makefile

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    da28563 View commit details
  7. Copy the full SHA
    d8f47ef View commit details
  8. Copy the full SHA
    306669d View commit details
  9. Add example.go

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    d370d0b View commit details
  10. Create build.yml

    bozd4g authored Nov 5, 2022
    Copy the full SHA
    c62c99b View commit details
  11. Remove comments

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    cefa61c View commit details
  12. Copy the full SHA
    b3d5329 View commit details
  13. Update readme

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    d649a57 View commit details
  14. Update readme

    bozd4g committed Nov 5, 2022
    Copy the full SHA
    3a1f856 View commit details

Commits on Nov 26, 2022

  1. Update response

    bozd4g committed Nov 26, 2022
    Copy the full SHA
    4ee0bb5 View commit details
  2. Update example

    bozd4g committed Nov 26, 2022
    Copy the full SHA
    b859e7b View commit details
  3. Update client and readme file

    bozd4g committed Nov 26, 2022
    Copy the full SHA
    4d14722 View commit details

Commits on Dec 4, 2022

  1. Remove travis yaml

    bozd4g committed Dec 4, 2022
    Copy the full SHA
    ca611b0 View commit details
  2. Copy the full SHA
    bc995a1 View commit details
  3. Update example

    bozd4g committed Dec 4, 2022
    Copy the full SHA
    e072e5d View commit details
  4. Update banner

    bozd4g committed Dec 4, 2022
    Copy the full SHA
    2485ea1 View commit details
  5. Copy the full SHA
    fac02d2 View commit details
  6. Update readme file

    bozd4g committed Dec 4, 2022
    Copy the full SHA
    6a26b00 View commit details
  7. Copy the full SHA
    3647beb View commit details

Commits on Dec 5, 2022

  1. Copy the full SHA
    ae08fba View commit details
  2. Update go module

    bozd4g committed Dec 5, 2022
    Copy the full SHA
    e029392 View commit details
  3. Copy the full SHA
    45d2a6d View commit details
  4. Copy the full SHA
    4915589 View commit details
  5. Update integration test

    bozd4g committed Dec 5, 2022
    Copy the full SHA
    0876845 View commit details
  6. Merge pull request #5 from bozd4g/bug/context-canceling-problem

    Context canceling problem
    bozd4g authored Dec 5, 2022
    Copy the full SHA
    a82330e View commit details
  7. Update unmarshal and tests

    bozd4g committed Dec 5, 2022
    Copy the full SHA
    4f23803 View commit details
  8. Update response tests

    bozd4g committed Dec 5, 2022
    Copy the full SHA
    1ee8790 View commit details
  9. Merge pull request #6 from bozd4g/bug/context-canceling-problem

    Update unmarshal and tests
    bozd4g authored Dec 5, 2022
    Copy the full SHA
    0f3708b View commit details

Commits on Dec 6, 2022

  1. Remove comments from test

    bozd4g committed Dec 6, 2022
    Copy the full SHA
    c8f9ef6 View commit details

Commits on Jan 28, 2024

  1. Remove test

    bozd4g committed Jan 28, 2024
    Copy the full SHA
    403729f View commit details
Showing with 1,036 additions and 396 deletions.
  1. +2 −2 .codecov.yml
  2. +54 −0 .github/workflows/build.yml
  3. +2 −1 .gitignore
  4. +0 −18 .travis.yml
  5. +9 −0 Makefile
  6. +28 −60 README.md
  7. BIN assets/banner.png
  8. BIN assets/github/logo.png
  9. +155 −60 client.go
  10. +360 −205 client_test.go
  11. +40 −0 example/example.go
  12. +8 −3 go.mod
  13. +3 −9 go.sum
  14. +61 −0 option.go
  15. +111 −0 option_test.go
  16. +41 −0 response.go
  17. +162 −0 response_test.go
  18. +0 −38 types.go
4 changes: 2 additions & 2 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
codecov:
require_ci_to_pass: yes
require_ci_to_pass: true

coverage:
precision: 2
@@ -17,4 +17,4 @@ parsers:
comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no
require_changes: false
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build & Test

on:
push:
branches: [ "master" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Build
run: go build -v ./...

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Test
run: make cov

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.txt
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Lint
run: go vet ./...
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#custom
yarn.lock
.env
coverage.out
coverage.txt

# globs
Makefile.in
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test:
@go test $(go list ./... | grep -v /example/)

cov:
@go test -coverprofile=coverage.txt -covermode=atomic $(go list ./... | grep -v /example/)

coverage:
$(MAKE) cov
@go tool cover -html=coverage.txt
88 changes: 28 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

<p align="center">
<a href="https://github.com/bozd4g/go-http-client">
<img alt="go-http-client" src="https://raw.githubusercontent.com/bozd4g/go-http-client/master/assets/github/logo.png" width="500">
<img alt="go-http-client" src="https://raw.githubusercontent.com/bozd4g/go-http-client/master/assets/banner.png" width="500">
</a>
</p>

@@ -19,7 +19,7 @@

<p align="center">
<a href="https://bozd4g.mit-license.org/"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a>
<a href="https://travis-ci.org/bozd4g/go-http-client"><img src="https://travis-ci.org/bozd4g/go-http-client.svg?branch=master"></a>
<a href="https://github.com/bozd4g/go-http-client/actions/workflows/build.yml"><img src="https://github.com/bozd4g/go-http-client/actions/workflows/build.yml/badge.svg"></a>
<a href="https://goreportcard.com/report/github.com/bozd4g/go-http-client"><img src="https://goreportcard.com/badge/github.com/bozd4g/go-http-client"></a>
<a href="https://codecov.io/gh/bozd4g/go-http-client">
<img alt="Coverage" src="https://codecov.io/gh/bozd4g/go-http-client/branch/master/graphs/badge.svg?branch=master">
@@ -31,78 +31,46 @@

This package provides you a http client package for your http requests. You can send requests quicly with this package. If you want to contribute this package, please fork and [create](https://github.com/bozd4g/go-http-client/pulls) a pull request.

# Installation
## Installation
```
$ go get -u github.com/bozd4g/go-http-client/
```

# Usage
## Example Usage
```go
package main

import (
"encoding/json"
"fmt"
client "github.com/bozd4g/go-http-client"
"context"
"log"

gohttpclient "github.com/bozd4g/go-http-client"
)

type Todo struct {
Id int
UserId int
Title string
Completed bool
type Post struct {
ID int `json:"id"`
Title string `json:"title"`
}

func main() {
httpClient := client.New("https://jsonplaceholder.typicode.com/")
request, err := httpClient.Get("posts/10")

if err != nil {
panic(err)
}

response, err := httpClient.Do(request)
if err != nil {
panic(err)
}

var todo Todo
err = json.Unmarshal(response.Get().Body, &todo)
if err != nil {
panic(err)
}
fmt.Println(todo.Title) // Lorem ipsum dolor sit amet

// or
var todo2 Todo
response, err = httpClient.Do(request)
if err == nil {
response.To(&todo2)
fmt.Println(todo2.Title) // Lorem ipsum dolor sit amet
} else {
fmt.Println(err.Error())
}
}
ctx := context.Background()
client := gohttpclient.New("https://jsonplaceholder.typicode.com")

response, err := client.Get(ctx, "/posts/1")
if err != nil {
log.Fatalf("error: %v", err)
}

var post Post
if err := response.Unmarshal(&post); err != nil {
log.Fatalf("error: %v", err)
}

log.Printf(post.Title) // sunt aut facere repellat provident occaecati...
}
```

## Functions
You can call these functions from your application.

| Function | Has Params |
| --------------------------------------------------------- | ---------- |
| Get(endpoint string) | - |
| GetWith(endpoint string, params interface {}) | Yes |
| Post(endpoint string) | - |
| PostWith(endpoint string, params interface {}) | Yes |
| Patch(endpoint string) | - |
| PatchWith(endpoint string, params interface{}) | Yes |
| Put(endpoint string) | - |
| PutWith(endpoint string, params interface{}) | Yes |
| Delete(endpoint string) | - |
| DeleteWith(endpoint string, params interface{}) | Yes |
| Do() (Response, error) | - |
| To(value interface{}) | - |

# License
## License
Copyright (c) 2020 Furkan Bozdag

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Binary file added assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/github/logo.png
Binary file not shown.
Loading