~mendelmaleh/dummy

ref: refs/heads/master dummy/cmd/dummyserver/api.md -rw-r--r-- 2.3 KiB View raw
39052d78Mendel E Add zip endpoint 12 hours ago

Endpoints

Being that this uses http.ServerMux, if you need to avoid caching you can add to your endpoint path, and it will still reach its correct handler. You can see the docs to learn more.

GET /

This is the main endpoint. You can pass it options as url query params, and it will return a png image.

GET /web/

This endpoint will return an HTML file, with OpenGraph meta tags, and a link to the generated image in og:image. It will take the same options as GET /, plus some specific to the meta tags.

Options

Options can be passed as URL query params. The options are described here as:

name    type    default_value   limitations

All options are, optional. There should always be a fallback value.

width   int 100 max:4096
height  int 100 max:4096

Set the width and height of the image. If only width is passed, height will be set to its value.

mask    string  "plain"

Set the mask for the image drawing. The different masks are:

  • plain: just a plain, one color, background.
  • diagonal: split diagonally, two colors.

TODO:

  • vertical: split vertically, two colors.
  • horizontal: split horizontally, two colors.
color   []string    []string{"#242933", "#eceff4"}

Set the colors to be used for the image. Hex strings can be in any of the following formats: rgb, rgba, rrggbb, rrggbbaa. It is not case-sensitive, hashes (#) at the start will be ignored, and alpha will be set to 255 (ie ff) if not passed. You can pass more than one color, and they will be used as needed.

desc    string  ""

This option is only available on the /web/ endpoint.

Set the og:description content.

Text options

text    string  ""

Set the text content to be rendered on the image. The text color will be the last passed color param.

font    string  ""

Set the font family for the text. There will be a default, set in the config.

size    float64     80.0    max:240.0

Set the font size for the text.

dpi     float64     72.0    max:720.0

Set the dpi for font rendering.

Text options (WIP)

center  string  "height"

Text can be set centered in two ways: on the actual height of the text, which can vary depending on the letter (ie, l is a lot taller than _), or on a consistent (among other letters in its font) baseline.