tupa

package module
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: MIT Imports: 23 Imported by: 1

README

🇧🇷 Tupã ⚡️

alt text

🇧🇷 Na mitologia Tupi Guarani, Tupã é o deus do trovão, criador de deuses, da humanidade, dos céus, mares, mundo animal e vegetal. O framework Tupã foi criado para te auxiliar na criação de projetos grandiosos e na velocidade da luz ⚡️

🇺🇸 In Tupi-Guarani mythology (a Brazilian indigenous tribe), Tupã is the god of thunder, creator of gods, humanity, the skies, seas, animals and forests. The Tupã framework was created to assist you in the development of ambitious projects at the speed of light ⚡️

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	GoogleOauthConfig = &oauth2.Config{
		ClientID:     "",
		ClientSecret: "",
		RedirectURL:  "",
		Scopes:       []string{""},
		Endpoint:     google.Endpoint,
	}
	GoogleWentWrongRedirUrl string

	LinkedinOauthConfig = &oauth2.Config{
		ClientID:     "",
		ClientSecret: "",
		RedirectURL:  "",
		Scopes:       []string{""},
		Endpoint:     linkedin.Endpoint,
	}
	LinkedingWentWrongRedirUrl string
)

Functions

func AddRoutes

func AddRoutes(groupMiddlewares MiddlewareChain, routeFuncs ...func() []RouteInfo)

func AuthGoogleHandler

func AuthGoogleHandler(tc *TupaContext) error

func AuthLinkedinCallback

func AuthLinkedinCallback(w http.ResponseWriter, r *http.Request) (map[string]interface{}, error)

func AuthLinkedinHandler

func AuthLinkedinHandler(tc *TupaContext) error

func FmtBlue

func FmtBlue(s string) string

func FmtRed

func FmtRed(s string) string

func FmtYellow

func FmtYellow(s string) string

func GenerateRandomStringHelper

func GenerateRandomStringHelper(length int) (string, error)

func UploadFile

func UploadFile(tc *TupaContext, filePrefix, destFolder, formFileKey string) (multipart.FileHeader, error)

func UseGoogleOauth

func UseGoogleOauth(clientID, clientSecret, redirectURL, googleWentWrongdRedirectURL string, scopes []string)

func UseLinkedinOauth

func UseLinkedinOauth(clientID, clientSecret, redirectURL, linkedinWentWrongRedirUrl string, scopes []string)

func WelcomeHandler

func WelcomeHandler(tc *TupaContext) error

func WriteJSONHelper

func WriteJSONHelper(w http.ResponseWriter, status int, v any) error

Types

type APIError

type APIError struct {
	Error string
}

type APIFunc

type APIFunc func(*TupaContext) error

type APIServer

type APIServer struct {
	// contains filtered or unexported fields
}

func NewAPIServer

func NewAPIServer(listenAddr string) *APIServer

func (*APIServer) GetGlobalMiddlewares

func (a *APIServer) GetGlobalMiddlewares() []MiddlewareFunc

func (*APIServer) MakeHTTPHandlerFuncHelper

func (a *APIServer) MakeHTTPHandlerFuncHelper(routeInfo RouteInfo, middlewares MiddlewareChain, globalMiddlewares MiddlewareChain) http.HandlerFunc

func (*APIServer) New

func (a *APIServer) New()

func (*APIServer) RegisterRoutes

func (a *APIServer) RegisterRoutes(routeInfos []RouteInfo)

func (*APIServer) UseGlobalMiddleware

func (a *APIServer) UseGlobalMiddleware(middleware ...MiddlewareFunc)

type Context

type Context interface {
	Request() *http.Request
	Response() http.ResponseWriter
	SendString(s string) error
	Param(param string) string
	QueryParam(param string) string
	QueryParams() map[string][]string
	SetRequest(r *http.Request)
	SetResponse(w http.ResponseWriter)
}

type GoogleAuthResponse

type GoogleAuthResponse struct {
	UserInfo GoogleDefaultResponse
	Token    *oauth2.Token
}

func AuthGoogleCallback

func AuthGoogleCallback(tc *TupaContext) (*GoogleAuthResponse, error)

type GoogleDefaultResponse

type GoogleDefaultResponse struct {
	ID            string `json:"id"`
	Email         string `json:"email"`
	VerifiedEmail bool   `json:"verified_email"`
	Name          string `json:"name"`
	GivenName     string `json:"given_name"`
	FamilyName    string `json:"family_name"`
	Picture       string `json:"picture"`
	Locale        string `json:"locale"`
	HostedDomain  string `json:"hd"`
}

type HTTPMethod

type HTTPMethod string
const (
	MethodGet     HTTPMethod = http.MethodGet
	MethodPost    HTTPMethod = http.MethodPost
	MethodPut     HTTPMethod = http.MethodPut
	MethodDelete  HTTPMethod = http.MethodDelete
	MethodPatch   HTTPMethod = http.MethodPatch
	MethodOptions HTTPMethod = http.MethodOptions
)

type LinkedinUserLocale

type LinkedinUserLocale struct {
	Country  string `json:"country"`
	Language string `json:"language"`
}

type MiddlewareChain

type MiddlewareChain []MiddlewareFunc

func (*MiddlewareChain) Use

func (chain *MiddlewareChain) Use(middleware ...MiddlewareFunc)

type MiddlewareFunc

type MiddlewareFunc func(APIFunc) APIFunc

type RouteInfo

type RouteInfo struct {
	Path        string
	Method      HTTPMethod
	Handler     APIFunc
	Middlewares []MiddlewareFunc
}

func GetRoutes

func GetRoutes() []RouteInfo

type TupaContext

type TupaContext struct {
	context.Context
	// contains filtered or unexported fields
}

func (*TupaContext) NewTupaContext

func (tc *TupaContext) NewTupaContext(w http.ResponseWriter, r *http.Request) *TupaContext

func (*TupaContext) Param

func (tc *TupaContext) Param(param string) string

func (*TupaContext) QueryParam

func (tc *TupaContext) QueryParam(param string) string

func (*TupaContext) QueryParams

func (tc *TupaContext) QueryParams() map[string][]string

func (*TupaContext) Request

func (tc *TupaContext) Request() *http.Request

func (*TupaContext) Response

func (tc *TupaContext) Response() *http.ResponseWriter

func (*TupaContext) SendString

func (tc *TupaContext) SendString(s string) error

func (*TupaContext) SetRequest

func (tc *TupaContext) SetRequest(r *http.Request)

func (*TupaContext) SetResponse

func (tc *TupaContext) SetResponse(w http.ResponseWriter)

Jump to

Keyboard shortcuts

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