http

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCorsHandler

func GetCorsHandler(e env.Env, urlMap UrlMap, allowedHeaders []string) (*cors.Cors, error)

GetCorsHandler returns a CORS handler configured based on the environment and port. It follows the principle of least privilege by restricting allowed origins based on environment, limits headers to a minimum of "Content-Type" and "Authorization" plus any additional headers provided, and allows only essential HTTP methods. Supplied Headers need not be case-sensitive and are normalized and sorted to ensure compatibility with the rs/cors library. It will return an error if the environment is not mapped to a URL. Multiple URL's can be provided per environment via the UrlMap.

GetCorsHandler(env.Development, UrlMap{env.Development: []string{"http://localhost:8081"}}, []string{"X-Custom-Header"})

Allows origin "http://localhost:8081" with Allowed-Headers: "Content-Type", "Authorization", "X-Custom-Header"

GetCorsHandler(env.Staging, UrlMap{env.Staging: []string{"https://staging.example.com"}}, []string{})

Allows origin "https://staging.example.com" with Allowed-Headers: "Content-Type", "Authorization"

Types

type UrlMap

type UrlMap map[env.Env][]string

Jump to

Keyboard shortcuts

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