Request: a HTTP request library for Go with interfaces and mocks for unit tests

Related tags

Network requester
Overview

Requester

Coverage Status

Request is a HTTP request library for Go with interfaces and mocks for unit tests.

The reason for having this package is using the interfaces to mock the HTTP requests easily on the codebase. Before creating this repository I was copying and pasting this package to my projects. So I decided to move this package to the separated package from my projects and use it with all of my projects.

How to use?

In your codebase, you should create a package called "requester" or with a name anything that you want. After that, you have to create exactly the same interfaces that the package provides. Right after that you can mock the methods and use them inside your unit tests.

Example:

package your_request_package

import (
	"github.com/dogukanayd/requester"
	"net/http"
)

type Requester interface {
	Get() (*http.Response, error)
	Post() (*http.Response, error)
	Put() (*http.Response, error)
}
You might also like...
A simple go program to proxy http request through a server with caching

go-http-proxy A simple go program to proxy http requests through a server with caching Usage All cli options are optional, and have the default values

DNS/HTTP request logging app
DNS/HTTP request logging app

Hotline DNS/HTTP request logging app Config: For a client, you can omit the server block. The below sample config shows all possible values. Please no

Httpecho - Golang HTTP echo server accepting malformed request

httpecho The same thing as jmalloc/echo-server but malformed HTTP requests are e

Simple-request-limiter - Example of limiting API requests using standard Go library

Route: http://localhost:8080/urls example of body in POST request that was used:

Http-server - A HTTP server and can be accessed via TLS and non-TLS mode

Application server.go runs a HTTP/HTTPS server on the port 9090. It gives you 4

Header Block is a middleware plugin for Traefik to block request and response headers which regex matched by their name and/or value

Header Block is a middleware plugin for Traefik to block request and response headers which regex matched by their name and/or value Conf

Capture packet request/response pairs for a port and/or IP to aid in Network protocol based Nuclei Templates creation.

network-fingerprint Capture packet request/response pairs for a port and/or IP to aid in Network protocol based Nuclei Templates creation. Resources I

a tcp framework which support pub/sub and request/reply

支持 事件订阅/请求回应 的的TCP通讯框架 源于 zinx 的业务定制版本 TCP 通讯框架 特点 服务端/客户端均支持订阅事件通讯. 服务端支持 Broadcast 方式发送信息到客户端. 客户端均支持 Request/Reply 方式与服务端通讯 服务端用多个worker去处理客户端的请求 目

Releases(v1.0.1)
  • v1.0.1(Jan 14, 2022)

    What's Changed

    • v1.0.1 | get request parameters as function param by @dogukanayd in https://github.com/dogukanayd/requester/pull/1

    New Contributors

    • @dogukanayd made their first contribution in https://github.com/dogukanayd/requester/pull/1

    Full Changelog: https://github.com/dogukanayd/requester/compare/v...v1.0.1

    Source code(tar.gz)
    Source code(zip)
  • v1.0.0(Jan 8, 2022)

Owner
Doğukan Aydoğdu
software engineer @useinsider, tech stack; whatever it takes but loves @golang
Doğukan Aydoğdu
Go package to simulate bandwidth, latency and packet loss for net.PacketConn and net.Conn interfaces

lossy Go package to simulate bandwidth, latency and packet loss for net.PacketConn and net.Conn interfaces. Its main usage is to test robustness of ap

Cevat Barış Yılmaz 313 Oct 14, 2022
Go network programming framework, supports multiplexing, synchronous and asynchronous IO mode, modular design, and provides flexible custom interfaces

Go network programming framework, supports multiplexing, synchronous and asynchronous IO mode, modular design, and provides flexible custom interfaces。The key is the transport layer, application layer protocol has nothing to do

rick.wu 11 Nov 7, 2022
Telemetry interfaces for logs and metrics allowing complete decoupling of instrumentation implementations.

Telemetry This package provides a set of Telemetry interfaces allowing you to completely decouple your libraries and packages from Logging and Metrics

Tetrate Labs 4 Aug 9, 2022
Go-libp2p-core. - Home to the interfaces and abstractions that make up go-libp2p

go-libp2p-core Home to the interfaces and abstractions that make up go-libp2p. I

Rohan 0 Jan 17, 2022
A framework for building chat interfaces with gioui.org.

chat A framework for building chat interfaces with gioui.org. The canonical copy of this repository is hosted on Sourcehut. We also have: An issue tra

null 9 Dec 1, 2022
A Golang protobuf plugin used to generate the necessary interfaces to interact with the database

protoc-gen-go-db-enum This protobuf compiler plugin generates the Valuer and Scanner interfaces for enums defined in the proto files. It is highly bas

Hellyson Rodrigo Parteka 1 Sep 9, 2022
Turbine-common - This package contains the common interfaces for Turbine that are shared with other software

turbine-common This package contains the common interfaces for Turbine that are

NoraSector 3 Feb 12, 2022
Protoc plugin to generate contract tests for gRPC in Go

Deal - Go Introduction WE DO NOT SUPPORT THE SERVER SIDE YET This plugin allows us to write Consumer-Driver Contracts tests! Usage example Proto servi

Faunists 15 Sep 3, 2022
Small template for a go service that includes postgres/redis/proxying/mocha tests

go-service-template Small template for a go service that includes postgres/redis/proxying/mocha tests All instances of this service are named 'foobar'

Rienzi Gokea 2 Feb 26, 2022
🧪 Run common networking tests against your site.

dstp dstp, run common networking tests against your site. Usage Usage: dstp [OPTIONS] [ARGS]

Yagiz Degirmenci 919 Jan 3, 2023