mmajis / plantuml-serverless

Serverless PlantUML diagram rendering
GNU General Public License v3.0
48 stars 22 forks source link

How to use plantuml API #19

Closed jiawei686 closed 3 years ago

jiawei686 commented 3 years ago

After deploying the serverless code, I know it's useful for vscode plugin. But can I use serverless plantuml api to render graph in my own app?

mmajis commented 3 years ago

Hi @jiawei686!

The serverless API is intended as a drop-in replacement for PlantUML Server. The API is described here: https://plantuml.com/server. You'll need to do the following to your diagram text content to send it over correctly:

  1. Encode in UTF-8
  2. Compress using Deflate or Brotli algorithm
  3. Re-encode in ASCII using a transformation close to base64 (this is a bit messy)
  4. Send a GET request to one of the paths which specify the response format, e.g. /png/

More discussion on the encoding here: https://plantuml.com/text-encoding

jiawei686 commented 3 years ago

Got it! Thanks a lot!