gomiddlewares

package module
v0.0.0-...-c7210ed Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 7 Imported by: 4

README

gomiddlewares

  • logger gin+zap
  • cors

Usage

Start using it

Download and install it:

$ go get github.com/judascrow/gomiddlewares

Import it in your code:

import "github.com/judascrow/gomiddlewares"

Example

See the example.

package main

import (
	"net/http"

	"github.com/gin-gonic/gin"
	"github.com/judascrow/gomiddlewares"
)

func main() {
	r := gin.New()

	r.Use(gomiddlewares.GoLogger())
	r.Use(gomiddlewares.GoCors())

	// Example ping request.
	r.GET("/test", func(c *gin.Context) {
		c.JSON(http.StatusOK, gin.H{
			"success": true,
			"message": "API is Online",
		})
	})

	// Listen and Server in 0.0.0.0:8080
	r.Run(":8080")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseLogFile

func CloseLogFile()

func GoCors

func GoCors() gin.HandlerFunc

func GoLogger

func GoLogger() gin.HandlerFunc

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