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.
Simple-REST requires Go version 1.22 or above.
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
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!
I welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -am 'Add new feature'
). - Push to the branch (
git push origin feature-branch
). - Create a new Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
For any questions or suggestions, feel free to open an issue.