• Stars
    star
    22
  • Rank 1,013,152 (Top 21 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 3 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Declarative golang HTTP client

go-req

GoDoc Build Status Coverage Status Go Report Card

Declarative golang HTTP client

package req_test

import (
    "fmt"
    "github.com/wenerme/go-req"
    "net/http"
)

func ExampleRequest() {
    // reusable client
    client := req.Request{
        BaseURL: "https://httpbin.org",
        Options: []interface{}{req.JSONEncode, req.JSONDecode},
    }
  
    // dump request and response with body
    client = client.WithHook(req.DebugHook(&req.DebugOptions{Body: true}))
    
    // send request with declarative override
    var out PostResponse
    var r *http.Response
    err := client.With(req.Request{
        Method: http.MethodPost,
        URL: "/post",
        Body: HelloRequest{
          Name: "go-req",
        },
    }).Fetch(&out,&r)
    if err != nil {
      panic(err)
    }
    // print go-req
    fmt.Println(out.JSON.Name)
    // print 200
    fmt.Println(r.StatusCode)
}

type HelloRequest struct {
  Name string
}
type HelloResponse struct {
  Name string
}
type PostResponse struct {
  JSON HelloResponse `json:"json"`
}

Used by

More Repositories

1

wener

Notes, Stories, Awesomes
JavaScript
171
star
2

go-rm

Write Redis module in Golang
C
153
star
3

go-wecom

Wechat Work/Wecom/企业微信 Golang SDK
Go
68
star
4

wode

Wener Node, Bun, NestJS, React Utils, Hooks & Demos
TypeScript
35
star
5

astgo

Libs for Go to work with Asterisk
Go
34
star
6

IKAnalyzer

IKAnalyzer 中文分词器
Java
32
star
7

winform.DropShadow

A winform DropShadow demo
C#
25
star
8

alpine-image

AlpineLinux pre-build disk images
Shell
23
star
9

kube-stub-cluster

Stub for Kubernetes Cluster Deployment by using ArgoCD/Helm/Kustomize
Smarty
16
star
10

bbvm

BeBasic Virtual Machine
Java
15
star
11

charts

HELM Charts Collections
Mustache
14
star
12

dockerfiles

Dockerfiles
Dockerfile
11
star
13

coredns-pdsql

CoreDNS PowerDNS adapter
Go
10
star
14

goaphql

Golang with GraphQL
Go
9
star
15

grpc-protos

A collection of grpc proto
Shell
9
star
16

postjava

Java work with PostgreSQL
Java
8
star
17

myfacility

MySQL facility in GO way
Go
7
star
18

awesome-alpine

A curated list of awesome Alpine linux relates.
6
star
19

apis

TypeScript
6
star
20

dotfiles

Relax dotfiles for Linux, Cygwin & Mac OSX
Shell
6
star
21

wps

Wener's Personal Service
Go
5
star
22

drifter

Flutter plugin work with device
Java
5
star
23

ansible-collection-wenerme-alpine

Ansible collection wener.alpine
Makefile
5
star
24

go-miniquery

SQL Where like filter expression for entql and gorm
Go
5
star
25

scel

Sougou scel dict - 搜狗 scel 词库工具
Go
4
star
26

alpine-admin

Ansible Role for Alpine Host
Python
4
star
27

GTetris

简单的俄罗斯方块, java swing
Java
4
star
28

jraphql

Java with GraphQL
Java
4
star
29

jss

MySQL Protocol Adapter for JDBC Connection
Java
3
star
30

coredns-ipin

CoreDNS plugin resolve the domain to ip in domain name
Go
3
star
31

boltdotnet

mirror for https://boltdotnet.codeplex.com/
C#
3
star
32

QQExportMessageParser

用于解析QQ的导出消息,目前只支持MHT的导出消息,和导出为 SQLit和JSON
C#
3
star
33

vimfiles

My vimfiles
Vim Script
2
star
34

seq

Distributed Sequence Generator
Java
2
star
35

repository

Alpine package repository for newer version or missing pack.
Shell
2
star
36

torrenti

Torrent Indexer
Go
2
star
37

tellets

A way to writing.
Java
2
star
38

node-yarn-starter

Yarn2 with NextJS and Gitlab CI
TypeScript
2
star
39

keycloak-services-cn

Keycloak 中国相关服务集成
Java
2
star
40

stardict

Library/Tools write in golang for Stardict/星际译王
Go
2
star
41

go-magic

libmagic in golang
Go
1
star
42

conlib

一个在控制台下编程的辅助库
C
1
star
43

tools

Index of Tools - ⚙🔩🔧
Go
1
star
44

asp.net.SaySay

我的ASP.NET作业,使用mongodb作为数据库,实现的一个发言的平台,SaySay意为 说说.
JavaScript
1
star
45

islove

IsLove app written in flutter/dart
Dart
1
star
46

go-net

Network for golang
Go
1
star
47

pm-exam-cheatsheet

软考项目管理考试知识整理
TypeScript
1
star
48

mapstruct-extras

MapStruct Extras
Java
1
star
49

go-gb

China GB implemented in Golang / Go 实现中国国家标准
Go
1
star
50

hv-annotation-with-group

Hibernate Validator - Constraint Annotation with Default group
Java
1
star