Documentation
¶
Index ¶
- Variables
- func AddRoutes(groupMiddlewares MiddlewareChain, routeFuncs ...func() []RouteInfo)
- func AuthGoogleHandler(tc *TupaContext) error
- func AuthLinkedinCallback(w http.ResponseWriter, r *http.Request) (map[string]interface{}, error)
- func AuthLinkedinHandler(tc *TupaContext) error
- func FmtBlue(s string) string
- func FmtRed(s string) string
- func FmtYellow(s string) string
- func GenerateRandomStringHelper(length int) (string, error)
- func UploadFile(tc *TupaContext, filePrefix, destFolder, formFileKey string) (multipart.FileHeader, error)
- func UseGoogleOauth(clientID, clientSecret, redirectURL, googleWentWrongdRedirectURL string, ...)
- func UseLinkedinOauth(clientID, clientSecret, redirectURL, linkedinWentWrongRedirUrl string, ...)
- func WelcomeHandler(tc *TupaContext) error
- func WriteJSONHelper(w http.ResponseWriter, status int, v any) error
- type APIError
- type APIFunc
- type APIServer
- func (a *APIServer) GetGlobalMiddlewares() []MiddlewareFunc
- func (a *APIServer) MakeHTTPHandlerFuncHelper(routeInfo RouteInfo, middlewares MiddlewareChain, ...) http.HandlerFunc
- func (a *APIServer) New()
- func (a *APIServer) RegisterRoutes(routeInfos []RouteInfo)
- func (a *APIServer) UseGlobalMiddleware(middleware ...MiddlewareFunc)
- type Context
- type GoogleAuthResponse
- type GoogleDefaultResponse
- type HTTPMethod
- type LinkedinUserLocale
- type MiddlewareChain
- type MiddlewareFunc
- type RouteInfo
- type TupaContext
- func (tc *TupaContext) NewTupaContext(w http.ResponseWriter, r *http.Request) *TupaContext
- func (tc *TupaContext) Param(param string) string
- func (tc *TupaContext) QueryParam(param string) string
- func (tc *TupaContext) QueryParams() map[string][]string
- func (tc *TupaContext) Request() *http.Request
- func (tc *TupaContext) Response() *http.ResponseWriter
- func (tc *TupaContext) SendString(s string) error
- func (tc *TupaContext) SetRequest(r *http.Request)
- func (tc *TupaContext) SetResponse(w http.ResponseWriter)
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 )
View Source
var AllowedMethods = map[HTTPMethod]bool{ MethodGet: true, MethodPost: true, MethodPut: true, MethodDelete: true, MethodPatch: true, MethodOptions: true, }
Functions ¶
func AddRoutes ¶
func AddRoutes(groupMiddlewares MiddlewareChain, routeFuncs ...func() []RouteInfo)
func AuthGoogleHandler ¶
func AuthGoogleHandler(tc *TupaContext) error
func AuthLinkedinCallback ¶
func AuthLinkedinHandler ¶
func AuthLinkedinHandler(tc *TupaContext) error
func UploadFile ¶
func UploadFile(tc *TupaContext, filePrefix, destFolder, formFileKey string) (multipart.FileHeader, error)
func UseGoogleOauth ¶
func UseLinkedinOauth ¶
func WelcomeHandler ¶
func WelcomeHandler(tc *TupaContext) error
func WriteJSONHelper ¶
func WriteJSONHelper(w http.ResponseWriter, status int, v any) error
Types ¶
type APIFunc ¶
type APIFunc func(*TupaContext) error
type APIServer ¶
type APIServer struct {
// contains filtered or unexported fields
}
func NewAPIServer ¶
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) RegisterRoutes ¶
func (*APIServer) UseGlobalMiddleware ¶
func (a *APIServer) UseGlobalMiddleware(middleware ...MiddlewareFunc)
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 MiddlewareChain ¶
type MiddlewareChain []MiddlewareFunc
func (*MiddlewareChain) Use ¶
func (chain *MiddlewareChain) Use(middleware ...MiddlewareFunc)
type MiddlewareFunc ¶
type RouteInfo ¶
type RouteInfo struct {
Path string
Method HTTPMethod
Handler APIFunc
Middlewares []MiddlewareFunc
}
type TupaContext ¶
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)
Click to show internal directories.
Click to hide internal directories.
