http

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2025 License: MIT Imports: 2 Imported by: 0

README

HTTP

This is a simple HTTP server powered by Fiber. With some customization to enchance the development experience and performance.

Documentation

Index

Constants

View Source
const (
	ErrorMetadataCode        = "code"
	ErrorMetadataUserMessage = "message"
)

Variables

This section is empty.

Functions

func JSONResponse added in v0.0.2

func JSONResponse(c fiber.Ctx, data interface{}, val error) error

JSONResponse is the function that will be used to send a JSON response. It will check if the error is a gerr.Error. If it is, it will send a JSON response with the error message. If it is not, it will send a JSON response with the data.

Types

type BaseResponse

type BaseResponse struct {
	Status  int     `json:"status"`
	Message *string `json:"message,omitempty"`
	Error   string  `json:"error"`
}

We can define a base response struct that will be used by all other response structs. This will help us to maintain a consistent response format across the application. This will also help us to easily change the response format in the future. Example:

 type TestResponse struct {
	*BaseResponse `json:"response,omitempty"`
	Data interface{} `json:"data"`
 }

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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