network

package
v0.1.31 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChainedMiddleware added in v0.1.25

func ChainedMiddleware(h http.HandlerFunc, m map[string]GeneralMiddleWare) http.HandlerFunc

Types

type Claim added in v0.1.8

type Claim struct {
	UserId     int64  `json:"id,omitempty"`
	FirstName  string `json:"fname,omitempty"`
	OtherNames string `json:"onames,omitempty"`
	Role       string `json:"role,omitempty"`
	IssuedAt   int64  `json:"iat,omitempty"`
	ExpiresAt  int64  `json:"eat,omitempty"`
}

func (*Claim) Valid added in v0.1.8

func (t *Claim) Valid() error

type GeneralMiddleWare

type GeneralMiddleWare func(handler http.Handler) http.HandlerFunc

type NetHandler

type NetHandler struct {
	Mux         *http.ServeMux
	Middlewares map[string]GeneralMiddleWare
}

func NewNetwork

func NewNetwork(mux *http.ServeMux, middlewares ...map[string]GeneralMiddleWare) *NetHandler

type Responses

type Responses struct{}

func (Responses) RespondAccepted

func (Responses) RespondAccepted(w http.ResponseWriter, r *http.Request)

accepted request

func (Responses) RespondBadRequest added in v0.1.24

func (Responses) RespondBadRequest(w http.ResponseWriter, r *http.Request, message ...string)

bad request

func (Responses) RespondCreated

func (Responses) RespondCreated(w http.ResponseWriter, r *http.Request, data any, message ...string)

post request

func (Responses) RespondDeleted

func (Responses) RespondDeleted(w http.ResponseWriter, r *http.Request)

delete request

func (Responses) RespondForbidden added in v0.1.24

func (Responses) RespondForbidden(w http.ResponseWriter, r *http.Request, data ...any)

forbidden

func (Responses) RespondOk

func (Responses) RespondOk(w http.ResponseWriter, r *http.Request, data any, message ...string)

get request

func (Responses) RespondUnauthorized added in v0.1.24

func (Responses) RespondUnauthorized(w http.ResponseWriter, r *http.Request)

unauthorized request

func (Responses) RespondUpdated

func (Responses) RespondUpdated(w http.ResponseWriter, r *http.Request)

put request

type TokenClaim added in v0.1.8

type TokenClaim interface {
	Valid() error
}

func GenerateClaim added in v0.1.8

func GenerateClaim(
	id int64,
	first_name string,
	other_names string,
	role string,
	expire_seconds int64,
) (TokenClaim, string, error)

Jump to

Keyboard shortcuts

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