Skip to content

A wrapper around http/net standard library in golang

License

Notifications You must be signed in to change notification settings

BragdonD/simple-rest

Repository files navigation

Simple-REST Web Framework

Simple-REST is a web framework written in Go. It is a simple wrapper around the net/http standard library. It has been developped to be as simple as possible while providing the most usefull utilities.

Getting started

Prerequisites

Simple-REST requires Go version 1.22 or above.

Getting Simple-REST

With Go's module support, go [build|run|test] automatically fetches the necessary dependencies when you add the import in your code:

import "github.com/bragdond/simple-rest"

Alternatively, use go get:

go get -u github.com/bragdond/simple-rest

Running Simple-REST

A basic example:

package main

import (
  "net/http"

  "github.com/simple-rest"
)

func handleHello(w http.ResponseWriter, r *http.Request, p simplerest.Parameters) error {
    w.WriteHeader(http.StatusAccepted)
    _, err :=w.Write([]byte(data))
    return err
}

func main() {
    server := simplerest.NewServer("localhost", 8080)
    server.HandleFunc("/hello", nil, handleHello, http.MethodGet)
	go server.Serve()
}

To run the code, use the go run command, like:

$ go run cmd/main.go

Then visit localhost:8080/hello in your browser to see the response!

Contributing

I welcome contributions! Please follow these steps to contribute:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -am 'Add new feature').
  5. Push to the branch (git push origin feature-branch).
  6. Create a new Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgements

Contact

For any questions or suggestions, feel free to open an issue.

About

A wrapper around http/net standard library in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published