captncraig / cors

Cross Origin Resource Sharing middleware for go
MIT License
19 stars 19 forks source link

Cannot build with the plugin #19

Open tufu9441 opened 4 years ago

tufu9441 commented 4 years ago

When I tried to build with the cors plugin by following steps (from https://github.com/caddyserver/caddy/tree/v1#install), the cors plugin cannot be compiled in:

  1. Create a new folder and within a main.go file as:
package main

import (
    "github.com/caddyserver/caddy/caddy/caddymain"
    _ "github.com/captncraig/cors"
        _ "github.com/caddyserver/forwardproxy"
)
func main() {
    // optional: disable telemetry
    // caddymain.EnableTelemetry = false
    caddymain.Run()
}
  1. Run go mod init caddy

  2. Run go get -u github.com/caddyserver/caddy image

  3. Run go build image

After the Caddy binary generated, I ran ./caddy -plugins and didn’t see the http.cors plugin listed, however the http.forwardproxy plugin can be seen. image

schlypel commented 4 years ago

Same here...

package main

import (
        "github.com/caddyserver/caddy/caddy/caddymain"
        _ "github.com/nicolasazrak/caddy-cache"
        _ "github.com/captncraig/cors"
        //_ ""
)

func main() {
        // optional: disable telemetry
        caddymain.EnableTelemetry = false
        caddymain.Run()
}

Cache Plugin is there, cors plugin missing.

May be relevant difference:

Is this plugin compatible with armv7 architectures? (RaspberryPi)

Silver-Golden commented 4 years ago

This may be a tad late for @tufu9441 but I experimented a tad and found that using

_ "github.com/captncraig/cors/caddy" worked for me, that gets it on teh list for me

schlypel commented 4 years ago

this is fixed by @Silver-Golden comment, can be closed afaik