httpreq is an http request library written with Golang to make requests and handle responses easily.

Related tags

HTTP Clients httpreq
Overview

httpreq

httpreq is an http request library written with Golang to make requests and handle responses easily.

Install

  go get github.com/binalyze/httpreq

Overview

httpreq implements a friendly API over Go's existing net/http library.

Req and Response are two most important struct. You can think of Req as a client that initiate HTTP requests, Resp as a information container for the request and response. They all provide simple and convenient APIs that allows you to do a lot of things.

req := httpreq.New(url)
resp, err := req.Get()

Roadmap

  • Support query parameters
  • Support cookies
  • Support XML
  • Support proxy
  • Configurable transport

Usage

Here is an example to use some helper methods of httpreq. You can find more examples in test files.

Request

req.SetHeaders(map[string]string{"Authorization": bearer}) // Set Content Type req.SetContentType("application/json") // Set JSON raw body info := &Data{ FirstName: "John", LastName: "Doe", Age: 42, } jsonData, _ := json.Marshal(info) req.SetBody(jsonData) // Send Request resp, _ := req.Post() ">
  // Create new request
  req := httpreq.New("https://your-address-to-send-json.com")

  // Set Timeout
  req.SetTimeout(30 * time.Second)

  // Set Header (i.e. JWT Bearer Token)
  var bearer = "Bearer " + <ACCESS TOKEN HERE>
  req.SetHeaders(map[string]string{"Authorization": bearer})

  // Set Content Type
  req.SetContentType("application/json") 

  // Set JSON raw body
  info := &Data{
    FirstName: "John",
    LastName:  "Doe",
    Age:       42,
  }

  jsonData, _ := json.Marshal(info)
	
  req.SetBody(jsonData)

  // Send Request
  resp, _ := req.Post()

Response

  // Body
  result, err := resp.Body()

  // Original response
  response := resp.Response()

  // StatusCode
  statusCode := resp.StatusCode()

  // Headers
  headers := resp.Headers()
Issues
  • Support query parameters

    Support query parameters

    We need to support query parameters. To do this we need a method like SetParam(params map[string]interface{}). Then this method will add the keys and values as query parameters to the requests.

    good first issue 
    opened by yakuter 11
  • Add context to request.

    Add context to request.

    We need context.Context to interrupt request. To do this, we should create new request like New(ctx, address). Then we shoud create request with this context.

    good first issue 
    opened by yakuter 4
  • Configurable transport

    Configurable transport

    Golang http clients has transport layer. So our transport layer should be configurable from outside. To achieve this we need a SetTransport helper as in the example. Then this method overwrites our request's transport (r.client.Transport)

    transport := &http.Transport{
    	// ...
    }
    
    req.SetTransport(transport)
    
    good first issue 
    opened by yakuter 2
  • Support proxy

    Support proxy

    We need to support proxy usage. To do this we need a method like SetProxy(url string). The url should contain both address and port like http://proxy.com:23456. Then this method will set the proxy to the request.

    good first issue 
    opened by yakuter 2
  • Support XML

    Support XML

    httpreq has only JSON support for now. However we should also support XML. To do this we need to;

    1. add XML header application/xml; charset=UTF-8 to request header
    2. create a method like SetBodyXML to set our request body as XML.
    good first issue 
    opened by yakuter 2
Owner
Binalyze
Incident Response re-imagined!
Binalyze
go http api to handle phishing resources requests

go http api to handle phishing resources requests (auth check, prometheus metrics, pushing to rabbit, logging to elasticsearch)

Dmitry Karpov 0 Oct 8, 2021
A golang tool which makes http requests and prints the address of the request along with the MD5 hash of the response.

Golang Tool This repository is a golang tool which makes http requests to the external server and prints the address of the request along with the MD5

null 0 Oct 17, 2021
Goget will send a http request, and show the request time, status, response, and save response to a file

Goget will send a http request, and show the request time, status, response, and save response to a file

LAZPbanahaker 2 Feb 9, 2022
A Go HTTP client library for creating and sending API requests

Sling Sling is a Go HTTP client library for creating and sending API requests. Slings store HTTP Request properties to simplify sending requests and d

Dalton Hubble 1.5k Jun 29, 2022
A fantastic HTTP request libarary used in Golang.

goz A fantastic HTTP request library used in golang. Inspired by guzzle Installation go get -u github.com/idoubi/goz Documentation API documentation

艾逗笔 225 Jun 21, 2022
Replacement of ApacheBench(ab), support for transactional requests, support for command line and package references to HTTP stress testing tool.

stress stress is an HTTP stress testing tool. Through this tool, you can do a stress test on the HTTP service and get detailed test results. It is ins

Wenjia Xiong 36 Mar 2, 2022
Gourl: Performs (multiple) HTTP requests and gathers stats

Gourl: Performs (multiple) HTTP requests and gathers stats

Maxime Le Conte des Floris 0 Mar 9, 2022
Nap is a file-based framework for automating the execution of config-driven HTTP requests and scripts.

Nap Nap is a file-based framework for automating the execution of config-driven HTTP requests and scripts. Installation Options Using go get $ go inst

Dave Sheldon 6 Feb 1, 2022
Go http.RoundTripper that emits open telemetry metrics. This helps you easily get metrics for all external APIs you interact with.

go-otelroundtripper This package provides an easy way to collect http related metrics (e.g Response times, Status Codes, number of in flight requests

Ndole Studio 20 Apr 14, 2022
Simple web-hook based receiver executing things via HTTP request

Updater is a simple web-hook-based receiver executing things via HTTP requests and invoking remote updates without exposing any sensitive info, like ssh keys, passwords, etc.

Umputun 36 May 21, 2022
This project aims for printing HTTP requests from outside simply

HTTP Debug Server This project aims for printing HTTP requests from outside simp

John Niang 1 Jan 29, 2022
A Go "clone" of the great and famous Requests library

GRequests A Go "clone" of the great and famous Requests library License GRequests is licensed under the Apache License, Version 2.0. See LICENSE for t

Levi Gross 1.9k Jun 26, 2022
Easybind - Bind req arguments easily in Golang

easybind Bind req arguments easily in Golang. Support Tag pos, specified that wh

wentx 3 May 1, 2022
Sample script to request test

Multiple request test script This script running in GO if not have compiler execute this: *** Open url: https://go.dev/dl/ download GO to your OS ***

Gabriel Piassa 1 Nov 23, 2021
Docker-Project - A simplified backend that listens to POST request

This is a simplified backend that listens to POST request. Once it receives such a request it will push it to a PostgreSQL database.

null 0 Feb 5, 2022
Speak HTTP like a local. (the simple, intuitive HTTP console, golang version)

http-gonsole This is the Go port of the http-console. Speak HTTP like a local Talking to an HTTP server with curl can be fun, but most of the time it'

mattn 65 Jul 14, 2021
Http client call for golang http api calls

httpclient-call-go This library is used to make http calls to different API services Install Package go get

pzenteno 14 Mar 8, 2022
fhttp is a fork of net/http that provides an array of features pertaining to the fingerprint of the golang http client.

fhttp The f stands for flex. fhttp is a fork of net/http that provides an array of features pertaining to the fingerprint of the golang http client. T

Flexagon 61 Jun 10, 2022
NATS HTTP Round Tripper - This is a Golang http.RoundTripper that uses NATS as a transport.

This is a Golang http.RoundTripper that uses NATS as a transport. Included is a http.RoundTripper for clients, a server that uses normal HTTP Handlers and any existing http handler mux and a Caddy Server transport.

R.I.Pienaar 75 Jun 14, 2022