langman

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2021 License: MIT Imports: 3 Imported by: 1

README

Langman

PkgGoDev

A useful gas that used to manage the Accept-Language header for the web applications built using Air.

Installation

Open your terminal and execute

$ go get github.com/air-gases/langman

done.

The only requirement is the Go, at least v1.13.

Usage

Create a file named main.go

package main

import (
	"github.com/air-gases/langman"
	"github.com/aofei/air"
)

func main() {
	a := air.Default
	a.DebugMode = true
	a.GET("/", func(req *air.Request, res *air.Response) error {
		return res.WriteString(req.Header.Get("Accept-Language"))
	}, langman.Gas(langman.GasConfig{}))
	a.Serve()
}

and run it

$ go run main.go

then visit http://localhost:8080/?accept-language=en-US.

Community

If you want to discuss Langman, or ask questions about it, simply post questions or ideas here.

Contributing

If you want to help build Langman, simply follow this to send pull requests here.

License

This project is licensed under the MIT License.

License can be found here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gas

func Gas(gc GasConfig) air.Gas

Gas returns an `air.Gas` that is used to manage the Accept-Language header based on the gc.

Types

type GasConfig

type GasConfig struct {
	// ParamName is the name of the param used to cover the original
	// Accept-Language header.
	//
	// Default: "accept-language"
	ParamName string

	// CookieName is the name of the cookie used to cover the original
	// Accept-Language header.
	//
	// Default: "accept-language"
	CookieName string

	// CookieMaxAge is the max-age of the cookie used to cover the original
	// Accept-Language header.
	//
	// Default: 0
	CookieMaxAge int

	Skippable func(*air.Request, *air.Response) bool
}

GasConfig is a set of configurations for the `Gas`.

Jump to

Keyboard shortcuts

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