web

package
v0.0.0-...-4109721 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package web contains a small web framework extension.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAPIKey

func NewAPIKey(length int) (string, error)

NewAPIKey is a factory function to create an api key with a specified length betweend 30 and 128 characters.

func Respond

func Respond(ctx context.Context, w http.ResponseWriter, data any, statusCode int)

Respond converts a Go value to JSON and sends it to the client.

Types

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"error"`
}

func NewErrorResponse

func NewErrorResponse(message string) ErrorResponse

type Handler

type Handler func(ctx context.Context, w http.ResponseWriter, r *http.Request) error

A Handler is a type that handles a http request within our small framework

Directories

Path Synopsis
Package mid contains the set of middleware functions.
Package mid contains the set of middleware functions.

Jump to

Keyboard shortcuts

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