gobin is a simple lightweight haste-server alternative written in Go, HTML, JS and CSS. It is easy to deploy and use. You can find a public version at xgob.in.
- Easy to deploy and use
- Create, update and delete documents
- Syntax highlighting
- Document expiration
- Only PostgreSQL required
- One binary and config file
- Docker image available
The easiest way to deploy gobin is using docker with Docker Compose. You can find the docker image on Packages.
Create a new docker-compose.yml file with the following content:
Note You should change the password in the
docker-compose.ymlandconfig.jsonfile.
version: "3.8"
services:
gobin:
image: ghcr.io/topisenpai/gobin:latest
container_name: gobin
restart: unless-stopped
volumes:
- ./config.json:/var/lib/gobin/config.json
ports:
- 80:80
postgres:
image: postgres:latest
container_name: postgres
restart: unless-stopped
volumes:
- ./data:/var/lib/postgresql/data
environment:
POSTGRES_DB: gobin
POSTGRES_USER: gobin
POSTGRES_PASSWORD: passwordFor config.json and database see schema Configuration.
docker-compose up -d- Go 1.18 or higher
- PostgreSQL 13 or higher
git clone https://github.com/TopiSenpai/gobin.git
cd gobin
go build -o gobinor
go install github.com/TopiSenpai/gobin@latestgobin --config=config.jsonCreate a new table in your PostgreSQL database with the following schema:
CREATE TABLE documents
(
id VARCHAR PRIMARY KEY,
content TEXT NOT NULL,
language VARCHAR NOT NULL,
update_token VARCHAR NOT NULL,
created_at TIMESTAMP NOT NULL,
updated_at TIMESTAMP NOT NULL
);Then create a new config.json file with the following content:
Note Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
{
"listen_addr": "0.0.0.0:80",
"expire_after": "168h",
"cleanup_interval": "10m",
"database": {
"host": "localhost",
"port": 5432,
"username": "gobin",
"password": "password",
"database": "gobin",
"ssl_mode": "disable"
}
}To create a paste you have to send a POST request to /documents with the content as plain/text body.
Note You can also specify the code language with the
Languageheader.
Language: go
package main
func main() {
println("Hello World!")
}
A successful request will return a 200 OK response with a JSON body containing the document key and token to update the document.
{
"key": "hocwr6i6",
"update_token": "kiczgez33j7qkvqdg9f7ksrd8jk88wba"
}To update a paste you have to send a PATCH request to /documents/{key} with the content as plain/text body and the update_token as Authorization header.
Note You can also specify the code language with the
Languageheader.
Authorization: kiczgez33j7qkvqdg9f7ksrd8jk88wba
Language: go
package main
func main() {
println("Hello World Updated!")
}
A successful request will return a 200 OK response with a JSON body containing the document key and token to update the document.
Note The update token will not change after updating the document. You can use the same token to update the document again.
{
"key": "hocwr6i6",
"update_token": "kiczgez33j7qkvqdg9f7ksrd8jk88wba"
}To delete a paste you have to send a DELETE request to /documents/{key} with the update_token as Authorization header.
gobin is licensed under the Apache License 2.0.
Contributions are always welcome! Just open a pull request or discussion and I will take a look at it.
- @Damon for helping me.