Skip to content

kmraven/simple-key-value-http-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Simple Key-Value HTTP Server

This is a lightweight HTTP server with key-value storage functionality. It allows you to store and retrieve data using specific keys through HTTP PUT and GET requests. (Implemented for Cybozu's internship pre-assignment)

Features

  • Listen for incoming connections on port 8000.
  • Handle requests to /objects/{key} where {key} is a string of up to 10 alphanumeric characters.
  • PUT Method:
    • Store arbitrary byte data in the request body under the specified key.
    • Responds with status code 200 upon successful storage.
  • GET Method:
    • Retrieve previously stored data associated with the specified key.
    • Responds with status code 200 and the data if found; responds with status code 404 if the key does not exist.
  • Other Methods:
    • Responds with status code 405 (Method Not Allowed) for unsupported methods.
  • All other paths:
    • Responds with status code 404 (Not Found).

Usage

  1. Start the server
% CGO_ENABLED=0 go run ./main.go
  1. Store data
% curl -X PUT -d "Hello, world!" http://localhost:8000/objects/mykey
  1. Retrieve data:
% curl http://localhost:8000/objects/mykey

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages