Sign inSign up

spoon4/goprince

By spoon4

•Updated about 8 years ago

RESTful API to generate PDF with Prince

Image
0

1.5K

spoon4/goprince repository overview

⁠goprince

Docker Layers Docker Build Status

Convert HTML files to PDF with Prince⁠ through an API.

⁠How to use?

$ goprince [--help] [--log-dir=/my/directory/] [--stdout] [--port 8080]
⁠Command line options
  • --help: show help
  • --log-dir: set Gin and Prince log directory. Default /var/log/goprince
  • --stdout: if given, Gin and Prince also log on stdout
  • --port: set port listening on. Default 8080

⁠API

⁠POST /generate/{filename}
⁠Parameters
  • filename string: Name of the output PDF file
⁠Body
  • input_file file: HTML file to convert (required)
  • stylesheet file: CSS file to upload to pass to Prince
⁠Query parameters
  • output string (optional):
    • stream: returns bytes of the file
    • file: serves PDF file to download
    • not present: returns file output path

⁠Env vars

VarDescription
APP_ENVdev / production
LICENSE_FILEPath to Prince license file
LICENSE_KEYPrince license hash key

⁠Logs

Both Prince and Gin are logged in separated files. Logs are written in the container, in /var/log/goprince folder.

In development environment, the Docker log directory is mapped on logs/ folder by a volume in docker-compose.yml⁠.

⁠Deployment

⁠In Development environment

To build the application's docker image run:

$ make build-dev

To launch a docker container run:

$ make run-dev

To access the API browse at

http://localhost:8080/

To access the conteneur with shell

$ make sh
⁠In Production environment

You can build a Docker image for your go application by running:

$ make build-prod

:warning: You need to increment number in VERSION⁠ file to increment Docker's image tag.

And to launch a docker container for the image created above we run:

$ make run-prod

⁠References

Tag summary

Content type

Image

Digest

Size

19.6 MB

Last updated

about 8 years ago

docker pull spoon4/goprince