restez

package module
v0.0.0-...-1fd42f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2023 License: MIT Imports: 4 Imported by: 0

README

restez

handling REST more EZ

curl -s -S -X POST http://localhost:8080/new -d '{"name": "Bob", "age": 45, "favoriteFood": "ice cream"}' | jq
curl -s -S -X POST http://localhost:8080/new -d '{"name": "Marty", "age": 13, "favoriteFood": "grapes"}' | jq

curl -s -S -X GET http://localhost:8080/list | jq

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleGET

func HandleGET[ResponseType any](fn func(map[string]string) (ResponseType, error)) http.HandlerFunc

HandleGET will parse the query string, and write a JSON response based on ResponseType

func HandlePOST

func HandlePOST[RequestType, ResponseType any](fn func(RequestType) (ResponseType, error)) http.HandlerFunc

HandlePOST will parse the request body with RequestType, and write a JSON response based on ResponseType.

func HandlePUT

func HandlePUT[RequestType, ResponseType any](fn func(RequestType) (ResponseType, error)) http.HandlerFunc

HandlePUT will parse the request body with RequestType, and write a JSON response based on ResponseType.

func WriteError

func WriteError(w http.ResponseWriter, err error)

func WriteJSON

func WriteJSON(w http.ResponseWriter, content any)

func WriteResponse

func WriteResponse(w http.ResponseWriter) func(any, error)

func WriteSuccess

func WriteSuccess(w http.ResponseWriter, response any)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL