http

package
v0.0.0-...-5b4c5eb Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: MIT Imports: 40 Imported by: 0

Documentation

Overview

Copied from https://github.com/zenazn/goji/blob/master/web/mutil/writer_proxy.go

Index

Constants

View Source
const (
	APITokenCookieName   = "apiToken"
	TrackingIDCookieName = "trackingId"
)

Variables

This section is empty.

Functions

func NewServer

func NewServer(
	args *interfaces.ServerArgs,
	errorRecorder *usecase.ErrorRecorder,
	userAPITokenUsecase *usecase.UserAPIToken,
) *server

func ParseAuthorizationHeader

func ParseAuthorizationHeader(header string) (string, error)

func ParseHTMLTemplates

func ParseHTMLTemplates(files ...string) *template.Template

func TemplateDir

func TemplateDir() string

func TemplatePath

func TemplatePath(file string) string

Types

type OAuthServer

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

func NewOAuthServer

func NewOAuthServer(
	appLogger *zap.Logger,
	errorRecorder *usecase.ErrorRecorder,
	gaMeasurementClient ga_measurement.Client,
	gaMeasurementUsecase *usecase.GAMeasurement,
	senderHTTPClient *http.Client,
	userUsecase *usecase.User,
	userAPITokenUsecase *usecase.UserAPIToken,
) *OAuthServer

func (*OAuthServer) Setup

func (s *OAuthServer) Setup(mux *goji.Mux)

type SendGridEventValues

type SendGridEventValues struct {
	Timestamp int64  `json:"timestamp"`
	Event     string `json:"event"`
	Email     string `json:"email"`
	SGEventID string `json:"sg_event_id"`
	UserAgent string `json:"useragent"`
	URL       string `json:"url"` // Only when event=click
	// Custom args
	EmailType  string `json:"email_type"`
	UserID     string `json:"user_id"`
	TeacherIDs string `json:"teacher_ids"`
}

func (*SendGridEventValues) GetUserID

func (v *SendGridEventValues) GetUserID() uint32

func (*SendGridEventValues) IsEventClick

func (v *SendGridEventValues) IsEventClick() bool

func (*SendGridEventValues) IsEventOpen

func (v *SendGridEventValues) IsEventOpen() bool

func (*SendGridEventValues) LogToDB

func (v *SendGridEventValues) LogToDB(db *gorm.DB) error

func (*SendGridEventValues) LogToFile

func (v *SendGridEventValues) LogToFile(logger *zap.Logger)

type WriterProxy

type WriterProxy interface {
	http.ResponseWriter
	// Status returns the HTTP status of the request, or 0 if one has not
	// yet been sent.
	Status() int
	// BytesWritten returns the total number of bytes sent to the client.
	BytesWritten() int
	// Tee causes the response body to be written to the given io.Writer in
	// addition to proxying the writes through. Only one io.Writer can be
	// tee'd to at once: setting a second one will overwrite the first.
	// Writes will be sent to the proxy before being written to this
	// io.Writer. It is illegal for the tee'd writer to be modified
	// concurrently with writes.
	Tee(io.Writer)
	// Unwrap returns the original proxied target.
	Unwrap() http.ResponseWriter
}

WriterProxy is a proxy around an http.ResponseWriter that allows you to hook into various parts of the response process.

func WrapWriter

func WrapWriter(w http.ResponseWriter) WriterProxy

WrapWriter wraps an http.ResponseWriter, returning a proxy that allows you to hook into various parts of the response process.

Jump to

Keyboard shortcuts

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