status_service.go   A
last analyzed

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 17
dl 0
loc 31
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A client.*statusService.Ok 0 17 4
1
package client
2
3
import (
4
	"context"
5
	"encoding/json"
6
	"net/http"
7
)
8
9
// statusService is the API client for the `/` endpoint
10
type statusService service
11
12
// Ok returns the 200 HTTP status Code.
13
//
14
// API Docs: https://httpstat.us
15
func (service *statusService) Ok(ctx context.Context) (*HTTPStatus, *Response, error) {
16
	request, err := service.client.newRequest(ctx, http.MethodGet, "/200", nil)
17
	if err != nil {
18
		return nil, nil, err
19
	}
20
21
	response, err := service.client.do(request)
22
	if err != nil {
23
		return nil, response, err
24
	}
25
26
	status := new(HTTPStatus)
27
	if err = json.Unmarshal(*response.Body, status); err != nil {
28
		return nil, response, err
29
	}
30
31
	return status, response, nil
32
}
33