Giter Site home page Giter Site logo

simple-go-server's Introduction

Simple Go HTTP Server

This project is a simple HTTP server built in Go (Golang), demonstrating basic CRUD operations without the use of external frameworks. The server allows the creation, retrieval, and deletion of posts, which are simple data structures stored in memory. This project is intended for educational purposes, showcasing Go's capabilities in handling HTTP requests, managing concurrency, and structuring a simple REST API.

There is an accompanying blog post, which you can find here: Building a Basic HTTP Server in Go: A Step by Step Tutorial.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing.

Prerequisites

Before running the server, ensure you have Go installed on your machine. The project was built using Go version 1.22.0, but it should be compatible with most Go versions. You can download Go from the official website.

Installing

To set up the project, clone the repository to your local machine:

git clone https://github.com/yourusername/simple-go-server.git
cd simple-go-server

Then, run the server using:

go run main.go

The server will start listening on http://localhost:8080. You can interact with the API through this base URL.

Running the tests

To execute the automated tests for this system, run the following command in the project directory:

go test

API Endpoints

The server defines the following RESTful endpoints:

GET /posts: Retrieve all posts.
GET /posts/{id}: Retrieve a single post by its ID.
POST /posts: Create a new post. The request body should contain the body field.
DELETE /posts/{id}: Delete a post by its ID.

simple-go-server's People

Contributors

andyjessop avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.