Skip to content
/ cors Public

W3C standard compliant full-featured CORS support for your proxies

License

Notifications You must be signed in to change notification settings

vinxi/cors

Repository files navigation

cors Build Status GoDoc Coverage Status Go Report Card

W3C standard compliant full-featured CORS support for your proxies.

Installation

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

API

See godoc reference.

Examples

Enable CORS with custom options

package main

import (
  "fmt"

  "gopkg.in/vinxi/cors.v0"
  "gopkg.in/vinxi/vinxi.v0"
)

const port = 3100

func main() {
  // Create a new vinxi proxy
  vs := vinxi.NewServer(vinxi.ServerOptions{Port: port})

  // Enable CORS support for all incoming traffic
  vs.Use(cors.New(cors.Options{
    AllowedOrigins: []string{"http://foo.com"},
    AllowedMethods: []string{"GET", "POST", "PUT", "DELETE"},
    AllowCredentials: true,
  }))

  // 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

W3C standard compliant full-featured CORS support for your proxies

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages