httpx

package module
v0.0.0-...-d71de7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 0 Imported by: 0

README

Overview

Package httpx provides out-of-box HTTP client/server settings and implementations.

Why we need a dedicated package for using HTTP?

Although Golang's builtin HTTP package (net/http) is battery included and highly performant, we still need to tune a few knobs, for example:

  • proper timeout settings in client & server to prevent exhausting server resource
  • up-to-date SSL/TLS setup for enforcing secure transport

It's tedious to remember and set them right for these subtle settings.

What's httpx approach?

To avoid repeating ourself, in httpx, we use scenario based approach to provide different out-of-box setups for different kind of services, clients.

We expect the service builder to import this package and let it configure everything by default.

But my application has configured many settings on the http server, will it be difficult to migrate?

httpx also provides adapter helpers for adapting existing implementations.

server usage

 package main

 import (
     "net/http"

     "hcp/toolkit/httpx/app"
 )

 func main() {
-    appServer := &http.Server{}
+    appServer, err := app.ApplyServer(&http.Server{})
+    if err != nil {
+        // handle err
+    }

     // ... continue to adapt other settings in the server instance
 }

Wait, how can you assure your implementation is attack-proof?

For each attack surface, we provide (or plan to provide) a set of tests to ensure the implementation can survive from the attack.

Below are the attack surfaces covered:

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft’s Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party’s policies.

Documentation

Overview

package httpx provides out-of-box HTTP client/server settings and implementations.

Please see README.md for more details.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL