Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lack a way to do simple request #38

Open
yookoala opened this issue Oct 12, 2018 · 2 comments
Open

Lack a way to do simple request #38

yookoala opened this issue Oct 12, 2018 · 2 comments
Assignees

Comments

@yookoala
Copy link
Owner

The current library presume library-users are working on a proxy to application server (as described in the FastCGI specification). But some library (e.g. https://github.com/tomasen/fcgi_client) works as a simple request-response interface for the application server.

gofast should also support this.

Conceptually, it should probably look like this

...

address := os.Getenv("FASTCGI_ADDR")

// A client to directly connect FCGI backend
f := gofast.SimpleClientFactory(gofast.SimpleConnFactory("tcp", address), 0)
client := gofast.NewDirectClient(f, ...)

// Request specifying "SCRIPT_FILENAME" and
// a small subset of usual header by default
// (user can supply more parameters)
req := gofast.NewDirectRequest(...)

// make the direct request
var resp http.Response := client.Do(req)

...
...

Connections are closed by the end of every session. Should be pretty straightforward to use.

@yookoala yookoala self-assigned this Oct 12, 2018
@thirdwheel
Copy link

thirdwheel commented Mar 17, 2020

Yes, this would be greatly appreciated. I've tried to roll my own without success - I just get a 500 error.

func directFS(root string) gofast.Middleware {
	fs := &gofast.FileSystemRouter{
		DocRoot: root,
		//Exts:     []string{""},
		DirIndex: []string{"index.html", "index.htm"},
	}
	return gofast.Chain(
		gofast.BasicParamsMap,
		gofast.MapHeader,
		fs.Router(),
	)
}

Since my FastCGI endpoint is a unix domain socket, I have limited testing capability. Any thoughts?

@thirdwheel
Copy link

thirdwheel commented Mar 17, 2020

By way of sanity check, I tested against php's fastcgi mode and no matter what filename I give it, I get 'No input file specified.'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants