-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
53 lines (43 loc) Β· 1021 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// Copyright (C) 2019 - 2023 Dmitry Kolesnikov
//
// This file may be modified and distributed under the terms
// of the MIT license. See the LICENSE file for details.
// https://github.com/fogfish/gurl
//
package main
import (
"context"
"github.com/fogfish/gurl/v2/http"
Ζ "github.com/fogfish/gurl/v2/http/recv"
ΓΈ "github.com/fogfish/gurl/v2/http/send"
)
// Declare the type, used for networking I/O.
type Payload struct {
Origin string `json:"origin"`
Url string `json:"url"`
}
// declares http I/O
func request() http.Arrow {
var data Payload
return http.GET(
// specify specify the request
ΓΈ.URI("https://httpbin.org/get"),
ΓΈ.Accept.ApplicationJSON,
// specify requirements to the response
Ζ.Status.OK,
Ζ.ContentType.JSON,
Ζ.Body(&data),
)
}
func main() {
// instance of http stack
stack := http.New(http.WithDebugPayload())
// declares http i/o
lazy := request()
// executes http I/O
err := stack.IO(context.Background(), lazy)
if err != nil {
panic(err)
}
}