Skip to content

nrfta/go-realip-in-context

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-realip-in-context

Reads Real IP from request and saves in context.

We use realip to find the client's real IP, then we save it to context. That allow us to get the client's IP in app code that doesn't have access to the request, only the context.

We expose a middleware and a function.

Usage

Examples use go-chi.

package main

import (
  // ...
  "github.com/nrfta/go-realip-in-context"
)

// ...
router := chi.NewRouter()

router.Use(realip.Middleware)
// ...
func something(ctx context.Context) {
  ip := realip.GetRealIP(ctx)

  fmt.Println(ip)
}

License

This project is licensed under the MIT License.

About

Reads Real IP from request and saves in context

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages