Skip to content

Commit

Permalink
CI: update module structure
Browse files Browse the repository at this point in the history
  • Loading branch information
btnguyen2k committed Feb 21, 2024
1 parent f149ac0 commit 96e5318
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 49 deletions.
49 changes: 0 additions & 49 deletions gjrc/gjrc.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,3 @@
/*
Package gjrc offers generic utilities to work with JSON-based RESTful API.
Sample usage:
package main
import (
"fmt"
"github.com/btnguyen2k/consu/gjrc"
"github.com/btnguyen2k/consu/reddo"
)
func main() {
// // pre-build a http.Client
// httpClient := &http.Client{}
// client := NewGjrc(httpClient, 0)
// or, a new http.Client is created with 10 seconds timeout
client := NewGjrc(nil, 10*time.Second)
url := "https://httpbin.org/post"
resp := client.PostJson(url, map[string]interface{}{"key1": "value", "key2": 1, "key3": true})
val1, err := resp.GetValueAsType("json.key1", reddo.TypeString)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", val1) // output: "value"
val2, err := resp.GetValueAsType("json.key2", reddo.TypeInt)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", val2) // output: 2
val3, err := resp.GetValueAsType("json.key3", reddo.TypeBool)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", val3) // output: true
}
*/
package gjrc

import (
Expand All @@ -60,11 +16,6 @@ import (
"github.com/btnguyen2k/consu/semita"
)

const (
// Version defines version number of this package
Version = "0.2.1"
)

// NewGjrc creates a new Gjrc object.
// It reuses the http.Client if supplied (then timeout is ignored). Otherwise, a new client is created with the
// specified timeout.
Expand Down
53 changes: 53 additions & 0 deletions gjrc/module.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
Package gjrc offers generic utilities to work with JSON-based RESTful API.
Sample usage:
package main
import (
"fmt"
"github.com/btnguyen2k/consu/gjrc"
"github.com/btnguyen2k/consu/reddo"
)
func main() {
// // pre-build a http.Client
// httpClient := &http.Client{}
// client := NewGjrc(httpClient, 0)
// or, a new http.Client is created with 10 seconds timeout
client := NewGjrc(nil, 10*time.Second)
url := "https://httpbin.org/post"
resp := client.PostJson(url, map[string]interface{}{"key1": "value", "key2": 1, "key3": true})
val1, err := resp.GetValueAsType("json.key1", reddo.TypeString)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", val1) // output: "value"
val2, err := resp.GetValueAsType("json.key2", reddo.TypeInt)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", val2) // output: 2
val3, err := resp.GetValueAsType("json.key3", reddo.TypeBool)
if err != nil {
panic(err)
}
fmt.Printf("%#v\n", val3) // output: true
}
*/
package gjrc

const (
// Version defines version number of this package
Version = "0.2.1"
)

// This file contains module's metadata only, which is package level documentation and module Version string.
// Module's code should go into other files.

0 comments on commit 96e5318

Please sign in to comment.