Skip to content

cooperneil/cowsay

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rundemo

Requests

To save a figure, send a POST request to your running service something to say.

curl -d "Hello World" -X POST https://[your_domain]/cows/[figure_name]

To retrieve a figure, send a GET request.

curl -i https://[your_domain]/cows/[figure_name]

No storage

When no env var is provided, the app won't connect to any storage. The POST request will fail and the GET request will always return a temporary figure.

With Redis

Provide the following env vars to configure a Redis connection

type RedisConn struct {
	Host string `envconfig:"REDIS_HOST"`
	Port int    `envconfig:"REDIS_PORT"`
}

The POST request will save the figure in the Redis instance with 20s expiration time. With that 20s, GET requests will get what you saved. After that, it will return 404. If the value is retrieved from the Redis, the response header will have x-cow-cache-hit=true.

With SQL

Provide the following env vars in addition to the Redis env vars

type SQLConn struct {
	Database string `envconfig:"DB_NAME"`
	User     string `envconfig:"DB_USER"`
	Password string `envconfig:"DB_PASS"`
	Socket   string `envconfig:"DB_SOCKET"`
}

The POST request will cache the figure in the Redis instance with 20s expiration time and persist the figure in the DB. GET requests will get what you saved. The Redis will work as a pass-through cache. If it's a cache hit, the response header will have x-cow-cache-hit=true.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%