Skip to content

Go (Golang) library for handling Client IP address, MIME-TYPE, ETags, and Quality Values in HTTP requests.

License

Notifications You must be signed in to change notification settings

THREATINT/go-http

Repository files navigation

go-http

Introduction

This is a library implemented in Go (Golang) that provides some functionality to deal with HTTP requests and certain headers.

Usage

Install using go get github.com/THREATINT/go-http.

Quality Values

Use ParseQualityValues() to parse client headers like Accept-Language. (e.g. fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5)

Please see RFC #9110, 12.4.2 Quality Values for details.

ClientIP

ClientIP() returns the client ip address from HTTP headers. It works with X-Forwarded-For (used by most reverse proxies) and is aware of True-Client-IP and CF-Connecting-IP (both implemented by CloudFlare) and others.

ETagMiddleware

ETagMiddleware() adds strong ETag headers to HTTP responses as defined in RFC #9110, 8.3.3 ETag.

MimeType

MimeTypeByExtension() provides a mapping for know file extension to mime type (e.g. .html -> text/html) based on the builtin mime.TypeByExtension and svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types.

Part of the source code for this functionality is generated by GenMimeType.py. (also provided in this repository)

Feedback

We would love to hear from you! Please contact us at help@fstpn.eu for feedback and general requests. Kindly raise an issue in Github if you find a problem in the code.

License

Release under the MIT License. (see LICENSE)

QA

Codacy Badge

About

Go (Golang) library for handling Client IP address, MIME-TYPE, ETags, and Quality Values in HTTP requests.

Topics

Resources

License

Stars

Watchers

Forks