From 3bacef551ee8656e802e14b231a725f146540ad8 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Mon, 14 Aug 2023 05:56:20 -0700 Subject: [PATCH] updated README.md file --- README.md | 40 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 99295f6..c856f31 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,14 @@ # go-errhttp -Package **errhttp** provides types errors that make dealing with HTTP response errors easier, for the Go programming language. +Package **errhttp** provides errors and types that make dealing with HTTP response errors easier, for the Go programming language. ## Example + +Here is an example of wrapping an error: + ```go - import "github.com/reiver/go-errhttp" + import "sourcecode.social/reiver/go-errhttp" // ... @@ -33,8 +36,37 @@ Package **errhttp** provides types errors that make dealing with HTTP response e } ``` +Here is an example of using one of the package global variable errors: + +```go + import "sourcecode.social/reiver/go-errhttp" + + // ... + + return errhttp.ErrBadRequest + + // ... + + switch err.(type) { + case errhttp.BadRequest: + //@TODO + case errhttp.NotFound: + //@TODO + case errhttp.InternalServerError: + //@TODO + + case errhttp.ClientError: + //@TODO + case errhttp.ServerError: + //@TODO + + default: + //@TODO + } +``` + ## Documention -Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-errhttp +Online documentation, which includes examples, can be found at: http://godoc.org/sourcecode.social/reiver/go-errhttp -[![GoDoc](https://godoc.org/github.com/reiver/go-errhttp?status.svg)](https://godoc.org/github.com/reiver/go-errhttp) +[![GoDoc](https://godoc.org/sourcecode.social/reiver/go-errhttp?status.svg)](https://godoc.org/sourcecode.social/reiver/go-errhttp)