Skip to content

Provides a plaintext version of a Mastodon post

Notifications You must be signed in to change notification settings

uhlig-it/plaintoot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plaintoot

Provides a plaintext representation of a Mastodon post ("toot").

Print

plaintoot print prints a plain-text representation of a single post. Provide a post's URL as an argument.

Run

Grab the latest release, unpack it and run plaintoot for more information.

There is also a Docker image; run it with:

$ docker run --interactive --tty --rm suhlig/plaintoot

Serve

plaintoot serve serves a plain-text representation of a single post via HTTP. It will start an HTTP server listening on $PORT (defaults to 8080) and provide the same functionality as print (see above).

With docker, this would be:

$ docker run --interactive --tty --rm --env PORT=8888 --publish 8090:8888 suhlig/plaintoot plaintoot serve

where we tell plaintoot to bind to port 8888 and then tell Docker to publish on port 8090 what's listening on port 8888 internally.

Develop

Install watchexec and start the server like this in order to reload the server process on any file changes:

$ STARTUP_DELAY=10s MAX_UPTIME=20s watchexec --restart go run . serve

The docker image can be built and pushed with

$ docker buildx build \
  --push \
  --platform linux/arm/v7,linux/arm64/v8,linux/amd64 \
  --tag suhlig/plaintoot

Bonus

This application is intended for use in my course "Web Services" at DHBW. For this purpose, it has some endpoints that showcase Kubernetes' liveness and readiness probes:

  • /liveness will generally return 200, unless the environment variable MAX_UPTIME was set to a value time.ParseDuration accepts and the given time since server start has elapsed. Other paths will still work, but /liveness will return 500 thereafter.
  • If STARTUP_DELAY is set, the application will sleep for the given duration (see above for the expected format), and only after that the HTTP port will be opened.
  • /readiness will return 200 if the authentication with Twitter is successful, otherwise 500 will be returned.

TODO

  • Add /metrics exposing
    • the number of requests since startup
    • uptime

About

Provides a plaintext version of a Mastodon post

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published