Skip to content

d1egoaz/plantuml-rest-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PlantUml Rest Service API

I created this tool trying to improve my local workflow as when I needed to render a new image I had to run java -jar plantuml.jar and JVM warm up is slow :(

Also I use org-mode to render PlantUml directly on emacs, but calling an external java process it just destroys the workflow.

I tried to use https://github.com/plantuml/plantuml-server but server is based on JEE and the protocol to call server needs some custom encoding. See js and python remote clients.

You can also use the server provided by PlantUml in http://www.plantuml.com/plantuml/png/, or might want to use all the available services online, but most of them are UI based and sometimes you don’t want to paste your diagrams on public services.

So, I just wrote a service that exposes an endpoint to create an image based on a plantuml string. I keep the service running on the background so there is no more JVM warming up involved.

This service can be integrated with any decent tool/IDE as it’s relaying on HTTP.

Tools used

I think it’s a good example of newcomers to Scala/Play as it’s using routing, DI, custom dispatchers. And it has Unit Tests :p

Example

@startuml
Diego -> World: hello
@enduml
echo "${text}" > /tmp/plantumltext.txt
curl -s -X POST --data-binary @/tmp/plantumltext.txt -H "Content-Type:text/plain" localhost:9000/plantuml/png > /tmp/plantuml.png

/tmp/plantuml.png

If you’re using curl remember to use `–data-binary` instead of `-d` to preserve line breaks

To know more about PlantUML, please visit http://plantuml.com/

Creating a fat jar

See https://www.playframework.com/documentation/2.5.x/Deploying#Using-the-dist-task

Using a precompiled jar

Just go to Releases. Download the latest version.

To run the application, unzip the file on the target server, and then run the script in the bin directory. Executable script comes in two versions, a bash shell script, and a windows .bat script.

$ unzip plantuml-rest-service-1.0-SNAPSHOT.zip
$ plantuml-rest-service-1.0-SNAPSHOT/bin/plantuml-rest-service
[info] play.api.Play - Application started (Prod)
[info] p.c.s.NettyServer - Listening for HTTP on /0:0:0:0:0:0:0:0:9000

License

This project uses PlantUML and that PlantUML is distributed under LGPL.

Roadmap/TODO:

  • Support additional image types.
  • json ???
  • Rewrite plantuml dependency in go.

Follow me on https://twitter.com/d1egoaz

About

Provides a simple Rest enpoint to create PlantUml images

Resources

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published

Languages