https://github.com/phogolabs/restify
Opinionated package for building HTTP RESTFul API
https://github.com/phogolabs/restify
form golang http json rest xml
Last synced: about 1 year ago
JSON representation
Opinionated package for building HTTP RESTFul API
- Host: GitHub
- URL: https://github.com/phogolabs/restify
- Owner: phogolabs
- License: mit
- Created: 2019-10-22T15:34:51.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-03-06T23:48:32.000Z (about 3 years ago)
- Last Synced: 2025-01-23T17:46:16.658Z (about 1 year ago)
- Topics: form, golang, http, json, rest, xml
- Language: Go
- Homepage:
- Size: 114 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# restify
[![Documentation][godoc-img]][godoc-url]
![License][license-img]
[![Build Status][action-img]][action-url]
[![Coverage][codecov-img]][codecov-url]
[![Go Report Card][report-img]][report-url]
An Opinionated package for building HTTP RESTFul API
## Installation
Make sure you have a working Go environment. Go version 1.13.x is supported.
[See the install instructions for Go](http://golang.org/doc/install.html).
To install `restify`, simply run:
```
$ go get github.com/phogolabs/restify
```
## Getting Started
```golang
type CreateUserInput struct {
FirstName string `json:"first_name" header:"-" validate:"required"`
LastName string `json:"last_name" header:"-" validate:"required"`
CreatedBy string `json:"-" header:"X-Created-By" validate:"-"`
}
type CreateUserOutput struct {
UserID string `json:"user_id"`
}
func (output *CreateUserOutput) Status() int {
return http.StatusCreated
}
func create(w http.ResponseWriter, r *http.Request) {
reactor := restify.NewReactor(w, r)
var (
input = &CreateUserInput{}
output = &CreateUserOutput{}
)
if err := reactor.Bind(input); err != nil {
reactor.Render(err)
return
}
// TODO: implement your logic here
if err := reactor.Render(output); err != nil {
reactor.Render(err)
return
}
}
```
## Contributing
We are open for any contributions. Just fork the
[project](https://github.com/phogolabs/restify).
[report-img]: https://goreportcard.com/badge/github.com/phogolabs/restify
[report-url]: https://goreportcard.com/report/github.com/phogolabs/restify
[codecov-url]: https://codecov.io/gh/phogolabs/restify
[codecov-img]: https://codecov.io/gh/phogolabs/restify/branch/master/graph/badge.svg
[action-img]: https://github.com/phogolabs/restify/workflows/main/badge.svg
[action-url]: https://github.com/phogolabs/restify/actions
[godoc-url]: https://godoc.org/github.com/phogolabs/restify
[godoc-img]: https://godoc.org/github.com/phogolabs/restify?status.svg
[license-img]: https://img.shields.io/badge/license-MIT-blue.svg
[software-license-url]: LICENSE