I am trying to work with this example code boost beast advanced server example
It compiles and works nice. Now i want to make it read from a given string to reply a Get or Post request instead of reading from a file.
For example: Client sends a Get request for "www.xxxxxxxxxx.com/index.html" Program will reply the request from a string which is taken from a database, not file.
How can i do it? Thanks.
The sample already shows it. Look, e.g. at how error responses are generated:
Just set
body()
to something different.DEMO
A full demo, basically just by stripping the sample from the unneeded code, and using
prepare_payload
to get content length/encoding automatically.