Thanks to visit codestin.com
Credit goes to github.com

Skip to content

zombi-HU/restful

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 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.

Reference.

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 and it can do logging. Router is based on Gorilla/Mux, offering similar services.
  • RESTful client Sending GET, POST (and receiving Location), PUT, PATCH or DELETE requests and receiving their responses. And numerous other helper functions.
  • Tracing information is propagated in context, received in Lambda and used in client request. That is all done without any extra coding on your side. Based on OpenTelemetry.
  • Monitor is a middleware that can pre-process requests and post-process responses. Pre and post hooks can be used for whatever you want, such as adding Prometheus counters on router level, without littering your business logic.
  • Error is a Go error object containing HTTP status code besides traditional error.

Trace context and error are the glue between Lambda and Client. That is why they form a module together.

Principles

  • Simple, intuitive, Go-ish.
  • Similar to Go's built-in http package, with some advanced router inherited from Gorilla/Mux project.
  • 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.2%
  • Other 0.8%