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

Possible to have multiple post handler and generated pages? #40

Open
DeqingSun opened this issue May 12, 2016 · 3 comments
Open

Possible to have multiple post handler and generated pages? #40

DeqingSun opened this issue May 12, 2016 · 3 comments

Comments

@DeqingSun
Copy link

Hi,

Is it possible to have multiple post handler with this library?
Also I'd like show whether the file is acceptable. Can I have a dynamically generated upload.html?

Thanks

@bakercp
Copy link
Owner

bakercp commented May 13, 2016

Hi there, can you explain what you mean by multiple post handler?

If you mean having multiple post endpoints, yes you can add multiple post route handlers, just make sure they have different route path patterns (the default is /post). You can change it here:

PostRouteSettings(const std::string& routePathPattern = DEFAULT_POST_ROUTE,
bool requireSecurePort = false,
bool requireAuthentication = false);

Also, you can set valid content types in the PostRouteSettings .. e.g.

/// \brief Set the list of valid Content Types.
/// \param validContentTypes A set of valid content types.
/// \note An empty set means that any requested Content-Type will be
/// accepted. A non-empty set means that the requested
/// The Content-Type MUST be in the set.
void setValidContentTypes(const MediaTypeSet& validContentTypes);

If the upload content type is not included, it will be rejected.

You can also set the upload redirect page here:

void setUploadRedirect(const std::string& uploadRedirect);

I'm not sure of the best return an "upload rejected" style message at the moment ... I think if you set a media type and the upload is incorrect, that will get you close ... but if you want to actually analyze the binary data using ofxLibmagic or something, that may need to be added as a feature.

@DeqingSun
Copy link
Author

Thanks for your reply,
Yes I'd like to have multiple post endpoints and I'm writing my own version of SimplePostServer.

Is it possible to print in a web response? Like I have a variable and I can see it's value on a web page?

@turiphro
Copy link

I'm also looking for an example to have multiple endpoints with their own handler.

It's clear you can change the endpoint for one particular PostRouteSettings, but how can we add multiple endpoints, each with their own handler, but running inside the same HTTP server?

https://github.com/bakercp/ofxHTTP/blob/master/example_basic_server_post/src/ofApp.cpp#L17-L36

There seems to be an addRoute method for the SimplePostServer class, but an example for setting multiple routes with their own handlers would be helpful.
https://bakercp.github.io/ofxHTTP/classofx_1_1_h_t_t_p_1_1_simple_post_server.html

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

No branches or pull requests

3 participants