statusHTTP

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 2 Imported by: 0

README

statusHTTP

Go Reference

Generate HTTP Errors with ease.

statusHTTP is a library written in go that helps in generating HTTP errors in a structured manner.

Install

If you don't have go installed, you can download it here.

$ go get github.com/itsknk/statusHTTP

After installing you can import it just like everyother library.

import (
    "github.com/itsknk/statusHTTP"
)

Usage

package main
import (
    "github.com/itsknk/statusHTTP"
	"net/http"
)
func myHandler(w http.ResponseWriter, r *http.Request) {
	statusHTTP.Forbidden(w, "Forbidden link")
}
func main() {
	http.HandleFunc("/", myHandler)
	http.ListenAndServe(":8080", nil)
}

Further Updates

  1. Have to add functions for handling more errors.

Contributing

  • Fork it and then do the changes or else download the zip file, test to make sure nothing is going sideways.
  • Make a pull request with a detailed explanation.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadGateway

func BadGateway(w http.ResponseWriter, message ...interface{})

BadGateway for 502

func BadRequest

func BadRequest(w http.ResponseWriter, message ...interface{})

BadRequest for 400

func Forbidden

func Forbidden(w http.ResponseWriter, message ...interface{})

Forbidden for 403

func Internal

func Internal(w http.ResponseWriter, message ...interface{})

Internal Server Error for 500

func NotFound

func NotFound(w http.ResponseWriter, message ...interface{})

NotFound for 404

func Unauthorized

func Unauthorized(w http.ResponseWriter, message ...interface{})

Unauthorized for 401

Types

This section is empty.

Jump to

Keyboard shortcuts

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