Skip to content
forked from nokia/restful

A powerful RESTful framework for Go.

License

Notifications You must be signed in to change notification settings

Som-Som-CC/restful

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful

Quick introduction

This Go package is a powerful extension of standard Go HTTP server and client libraries. It lets you handle HTTP+JSON without any extra code.

Lambda server

You receive and respond with data structures.

type reqData struct{...}
type respData struct{...}

func create(ctx context.Context, req *reqData) (*respData, error) {
    ... // You use data structures directly, without marshalling and unmarshalling.
}

func main() {
    restful.HandleFunc("/user/v1", create).Methods(http.MethodPost)
    restful.Start()
}

RESTful client

You send and receive data structures.

location, err := restful.Post(ctx, "https://example.com", &reqData, &respData)

Details

  • Lambda server Focus on business logic. It is a modern variant of an HTTP server.
  • RESTful server An underlying HTTP server of Lambda. An HTTP server with goodies. Besides helper functions for receiving and sending JSON data, it can do logging, and provides Monitor hooks for whatever you need, such as adding Prometheus counters without littering your code.
  • RESTful client Such as sending GET, POST (and receiving Location), PUT, PATCH or DELETE requests and receiving their responses. And numerous other helper functions.
  • Context is received in Lambda and used in client request. That is highly important, as some tracing headers should propagate from service to service (with some changes). That is all done without any extra coding on your side.
  • Error is used by Lambda, Server and Client classes. It contains HTTP status code besides traditional error.

Context and error are the glue between Lambda and Client.

Principles

  • Simple, intuitive, Go-ish.
  • Similar to Go's built-in http package and the famous Gorilla/Mux.
  • Powerful HTTP+JSON framework reducing development costs while improving quality.
  • Have quite many goodies needed on developing complex applications.

About

A powerful RESTful framework for Go.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.1%
  • Other 0.9%