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

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()
Owner
Binalyze
Incident Response re-imagined!
Binalyze
Comments
  • 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.

  • 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.

  • 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)
    
  • 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.

  • 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.
Related tags
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)

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

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

Feb 9, 2022
A Go HTTP client library for creating and sending API requests
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

Jan 7, 2023
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

Dec 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

Aug 23, 2022
Gourl: Performs (multiple) HTTP requests and gathers stats

Gourl: Performs (multiple) HTTP requests and gathers stats

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

Nov 17, 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

Jan 8, 2023
This project aims for printing HTTP requests from outside simply

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

Jan 29, 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.

Dec 19, 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

Dec 23, 2022
Easybind - Bind req arguments easily in Golang

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

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 ***

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.

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'

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

Oct 7, 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

Jan 1, 2023
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.

Dec 6, 2022