FlowServer

package module
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 17 Imported by: 1

README

FlowServer

FlowServer is a Go library designed to simplify the creation of robust and scalable HTTP servers using the Gin framework. It integrates Swagger for API documentation, logging with Gin middleware, and makes server initialization effortless.


Features

  • Effortless Server Initialization: Quickly bootstrap a Gin-based HTTP server with minimal configuration.
  • Swagger Integration: Automatically generates API documentation using swag based on annotations in your code.
  • Logging Middleware: Provides request logging with IP anonymization for GDPR compliance.
  • Dynamic Configuration: Supports environment-based configuration for production and development.
  • Asynchronous Server Start: Easily integrate with other concurrent components in your application.

Installation

Import in other projects:

export GOPRIVATE=github.com/LucaSchmitz2003/*
GIT_SSH_COMMAND="ssh -v" go get github.com/LucaSchmitz2003/FlowServer@main

Usage

Server Initialization:

ctx := context.Background()

// Initialize the server
address, router := apiHelper.InitServer(ctx, defineRoutes)

// Start the server in a goroutine
keepAlive := apiHelper.StartServer(ctx, router, address)
defer keepAlive()

Licenses

This project is licensed under the MIT License. It uses third-party libraries that are licensed under the following terms (direct dependencies only):

  • BSD-3-Clause License
  • Apache License 2.0

Please refer to the respective license texts of these libraries, which are referenced in go.mod. By using this project, you agree to comply with the license terms of these third-party dependencies.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CORSMiddleware added in v0.2.0

func CORSMiddleware(ctx context.Context, acceptedOrigins []string) gin.HandlerFunc

func InitServer

func InitServer(ctx context.Context, defineRoutes DefineRoutesFunc, acceptedOrigins []string) (string, *gin.Engine)

InitServer initializes the server and returns the server address and router.

func StartServer

func StartServer(ctx context.Context, router *gin.Engine, address string) func()

StartServer starts the server asynchronously and returns a keep-alive function for deferred use.

Types

type DefineRoutesFunc

type DefineRoutesFunc func(ctx context.Context, router *gin.Engine)

Jump to

Keyboard shortcuts

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