Skip to content

vinxi/apachelog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

apachelog Build Status GoDoc Coverage Status Go Report Card

Apache style logging middleware for your proxies. Uses apachelog.

Installation

go get -u gopkg.in/vinxi/apachelog.v0

API

See godoc reference.

Example

Default log to stdout

package main

import (
  "fmt"
  "gopkg.in/vinxi/apachelog.v0"
  "gopkg.in/vinxi/vinxi.v0"
)

const port = 3100

func main() {
  // Create a new vinxi proxy
  vs := vinxi.NewServer(vinxi.ServerOptions{Port: port})
  
  // Attach the log middleware 
  vs.Use(log.Default)
  
  // Target server to forward
  vs.Forward("http://httpbin.org")

  fmt.Printf("Server listening on port: %d\n", port)
  err := vs.Listen()
  if err != nil {
    fmt.Errorf("Error: %s\n", err)
  }
}

Using a custom io.Writer

package main

import (
  "fmt"
  "os"
  "gopkg.in/vinxi/apachelog.v0"
  "gopkg.in/vinxi/vinxi.v0"
)

const port = 3100

func main() {
  // Create a new vinxi proxy
  vs := vinxi.NewServer(vinxi.ServerOptions{Port: port})
  
  // Attach the log middleware 
  vs.Use(log.New(os.Stdout))
  
  // Target server to forward
  vs.Forward("http://httpbin.org")

  fmt.Printf("Server listening on port: %d\n", port)
  err := vs.Listen()
  if err != nil {
    fmt.Errorf("Error: %s\n", err)
  }
}

License

MIT

About

Apache-style logging middleware

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages