webapp

package module
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 4 Imported by: 3

README

webapp

Reusable components and helper functions for common use cases for Go based web applications.

Installation

The webapp module can be installed by running the the following command in your main Go module:

go get github.com/qqiao/webapp
Usage

API documentation and example code can be found at the pkg.go.dev.

Documentation

Overview

Package webapp provides reusable components and helper functions for common use cases for Go web applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetermineLocale added in v1.0.3

func DetermineLocale(input string, available []string) string

DetermineLocale tries to find the best locale for a given input from a list of available locales. It applies the following logic:

  1. If the input can be directly found in list of available locales, it will be returned directly.
  2. If a less specific value is available, then it will be returned. E.g. if the input is zh-tw but zh is available then zh will be returned
  3. Otherwise, an empty string is returned.

func DetermineLocaleWithDefault added in v1.0.4

func DetermineLocaleWithDefault(input string, available []string) string

DetermineLocaleWithDefault tries to find the best locale for a given input from a list of available locales. It applies the following logic:

  1. If the input can be directly found in list of available locales, it will be returned directly.
  2. If a less specific value is available, then it will be returned. E.g. if the input is zh-tw but zh is available then zh will be returned
  3. If no locale can be found, the first entry in available will be returned. If available is empty, an empty string will be returned. It is down to the caller of the function to handle such situation.

func GetTemplate

func GetTemplate(path string, skipCache bool) *template.Template

GetTemplate loads the template from the given path.

The function caches the loaded template so that the same template would not be parsed over and over again unless skipCache is set to true.

Please note this method panics if template.ParseFiles fails in any way.

func HSTSHandler

func HSTSHandler(f http.HandlerFunc) http.HandlerFunc

HSTSHandler takes a normal HTTP handler and adds the capability of sending HSTS headers.

Types

This section is empty.

Directories

Path Synopsis
Package auth contains all functions regarding user authentication.
Package auth contains all functions regarding user authentication.
rememberme
Package rememberme contains all functionalities regarding the storage and validation of the rememberme tokens.
Package rememberme contains all functionalities regarding the storage and validation of the rememberme tokens.
user
Package user implements a basic user management system.
Package user implements a basic user management system.
Package datastore provides abstraction to datastore operations.
Package datastore provides abstraction to datastore operations.
Package firebase contains helper function for commonly used firebase functionalities.
Package firebase contains helper function for commonly used firebase functionalities.
firestore
Package firestore contains data structures and helper functions for using firebase firestore.
Package firestore contains data structures and helper functions for using firebase firestore.
Package jwt contains functions related to JWT signing and validation.
Package jwt contains functions related to JWT signing and validation.

Jump to

Keyboard shortcuts

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