Versions in this module Expand all Collapse all v0 v0.0.9 Dec 16, 2025 v0.0.8 Dec 15, 2025 Changes in this version type Context + SSE func(handler SSEHandler) error + type SSEEvent struct + Data string + Event string + ID string + Retry int + func (e SSEEvent) String() string + type SSEHandler func(SSEWriter) error + type SSEWriter interface + Flush func() + Send func(data string) error + SendEvent func(event SSEEvent) error + func NewSSEWriter(w http.ResponseWriter) SSEWriter v0.0.3 May 16, 2025 Changes in this version + const DEFAULT_AFTER_HANDLER + const DEFAULT_BEFORE_HANDLER + const DEFAULT_HTTP_CONCURRENCY + const DEFAULT_HTTP_IDLE_TIMEOUT + const DEFAULT_HTTP_READ_TIMEOUT + const DEFAULT_HTTP_WRITE_TIMEOUT + const SIMPLEHTTP_APP_NAME + const SIMPLEHTTP_DEBUG + const SIMPLEHTTP_FRAMEWORK + const SIMPLEHTTP_FRAMEWORK_STARTUP_MESSAGE + const SIMPLEHTTP_HOST_NAME + const SIMPLEHTTP_IDLE_TIMEOUT + const SIMPLEHTTP_INTERNAL_API + const SIMPLEHTTP_INTERNAL_STATUS + const SIMPLEHTTP_PORT + const SIMPLEHTTP_READ_TIMEOUT + const SIMPLEHTTP_WRITE_TIMEOUT + var HEADER_API_KEY string = "API_KEY" + type Context interface + Bind func(interface{}) error + BindForm func(interface{}) error + BindJSON func(interface{}) error + Context func() context.Context + Get func(key string) interface{} + GetBody func() []byte + GetFile func(fieldName string) (*multipart.FileHeader, error) + GetHeader func(key string) string + GetHeaders func() *RequestHeader + GetMethod func() string + GetPath func() string + GetQueryParam func(key string) string + GetQueryParams func() map[string][]string + JSON func(code int, data interface{}) error + Request func() *http.Request + Response func() http.ResponseWriter + SaveFile func(file *multipart.FileHeader, dst string) error + SendFile func(filepath string, attachment bool) error + Set func(key string, value interface{}) + SetContext func(ctx context.Context) + SetHeader func(key, value string) + SetRequestHeader func(key, value string) + SetResponseHeader func(key, value string) + Stream func(code int, contentType string, reader io.Reader) error + String func(code int, data string) error + Upgrade func() (Websocket, error) type DefaultLogger + func (l *DefaultLogger) IsAfterHandler() bool + func (l *DefaultLogger) IsBeforeHandler() bool + func (l *DefaultLogger) IsPrintRequestID() bool type DefaultLoggerConfig + AfterHandler bool + BeforeHandler bool + type HandlerFunc func(Context) error type Logger + IsAfterHandler func() bool + IsBeforeHandler func() bool + IsPrintRequestID func() bool + type Middleware interface + Handle func(HandlerFunc) HandlerFunc + Name func() string + type MiddlewareFunc func(HandlerFunc) HandlerFunc type RequestHeader + MedaAPIKey string + type Router interface + DELETE func(path string, handler HandlerFunc) + GET func(path string, handler HandlerFunc) + Group func(prefix string) Router + HEAD func(path string, handler HandlerFunc) + OPTIONS func(path string, handler HandlerFunc) + PATCH func(path string, handler HandlerFunc) + POST func(path string, handler HandlerFunc) + PUT func(path string, handler HandlerFunc) + Static func(prefix, root string) + StaticFile func(path, filepath string) + Use func(middleware ...Middleware) + WebSocket func(path string, handler func(Websocket) error) + type Server interface + Shutdown func(ctx context.Context) error + Start func(address string) error + type SimpleHttpError struct + Code int + Details interface{} + Message string + func (e *SimpleHttpError) Error() string + type Websocket interface + Close func() error + ReadJSON func(v interface{}) error + ReadMessage func() (messageType int, p []byte, err error) + WriteJSON func(v interface{}) error + WriteMessage func(messageType int, data []byte) error v0.0.2 Apr 16, 2025 v0.0.1 Apr 14, 2025 Changes in this version + const DEFAULT_INTERNAL_API + const DEFAULT_INTERNAL_STATUS + const FRAMEWORK_STARTUP_MESSAGE + const HEADER_ACCEPT_TYPE + const HEADER_AUTHORIZATION + const HEADER_CODE + const HEADER_CONNECTING_IP + const HEADER_FORWARDED_FOR + const HEADER_MEDA_API_KEY + const HEADER_ORIGIN + const HEADER_PRIVATE_TOKEN + const HEADER_REAL_IP + const HEADER_REQUEST_ID + const HEADER_TRACE_ID + const HEADER_TRUE_CLIENT_IP + const HEADER_USER_AGENT + const INTERNAL_API + const INTERNAL_STATUS + const MEDA_APP_NAME + const MEDA_DEBUG + const MEDA_DEFAULT_HTTP_CONCURRENCY + const MEDA_DEFAULT_HTTP_IDLE_TIMEOUT + const MEDA_DEFAULT_HTTP_READ_TIMEOUT + const MEDA_DEFAULT_HTTP_WRITE_TIMEOUT + const MEDA_FRAMEWORK + const MEDA_HOST_NAME + const MEDA_IDLE_TIMEOUT + const MEDA_PORT + const MEDA_READ_TIMEOUT + const MEDA_WRITE_TIMEOUT + const REQUEST_HEADER_PARSED_STRING + var DefaultConfig = &Config + var ErrForbidden = fmt.Errorf("forbidden") + var ErrInvalidConfig = fmt.Errorf("invalid configuration") + var ErrNotFound = fmt.Errorf("resource not found") + var ErrRateLimitExceeded = fmt.Errorf("limit exceeded") + var ErrServerStartup = fmt.Errorf("server startup failed") + var ErrUnauthorized = fmt.Errorf("unauthorized") + var PathInternalAPI string = DEFAULT_INTERNAL_API + var PathInternalStatus string = DEFAULT_INTERNAL_STATUS + func GenerateRequestID() string + func ValidateConfig(config *Config) error + type CORSConfig struct + AllowCredentials bool + AllowHeaders []string + AllowMethods []string + AllowOrigins []string + ExposeHeaders []string + MaxAge time.Duration + type CacheConfig struct + IgnoreHeaders []string + KeyFunc func(MedaContext) string + KeyPrefix string + Store CacheStore + TTL time.Duration + type CacheStore interface + Clear func() error + Delete func(key string) error + Get func(key string) (interface{}, bool) + Set func(key string, value interface{}, ttl time.Duration) error + func NewMemoryCache() CacheStore + type CompressionConfig struct + Level int + MinSize int64 + Types []string + type Config struct + AllowedHosts []string + AppName string + AutoTLS bool + Concurrency int + ConfigCORS *CORSConfig + ConfigTimeOut *TimeOutConfig + Debug bool + ErrorHandler func(error, MedaContext) error + Framework string + FrameworkStartupMessage bool + Hostname string + Logger Logger + MaxHeaderBytes int + MaxRequestSize int64 + Port string + SSLRedirect bool + TLSCert string + TLSDomain string + TLSKey string + TempDir string + TrustedProxies []string + UploadDir string + func LoadConfig() *Config + type DefaultLogger struct + func (l *DefaultLogger) Debug(v ...interface{}) + func (l *DefaultLogger) Debugf(format string, v ...interface{}) + func (l *DefaultLogger) Error(v ...interface{}) + func (l *DefaultLogger) Errorf(format string, v ...interface{}) + func (l *DefaultLogger) Fatal(v ...interface{}) + func (l *DefaultLogger) Fatalf(format string, v ...interface{}) + func (l *DefaultLogger) Info(v ...interface{}) + func (l *DefaultLogger) Infof(format string, v ...interface{}) + func (l *DefaultLogger) Print(v ...interface{}) + func (l *DefaultLogger) Printf(format string, v ...interface{}) + func (l *DefaultLogger) Warn(v ...interface{}) + func (l *DefaultLogger) Warnf(format string, v ...interface{}) + type DefaultLoggerConfig struct + Level LogLevel + Output io.Writer + Prefix string + PrintRequestID bool + TimeFormat string + type FileHandler struct + AllowedTypes []string + MaxFileSize int64 + UploadDir string + func NewFileHandler(uploadDir string) *FileHandler + func (h *FileHandler) HandleDownload(filepath string) MedaHandlerFunc + func (h *FileHandler) HandleUpload() MedaHandlerFunc + type FileInfo struct + ContentType string + Filename string + Hash string + LastModified time.Time + Size int64 + type HeaderAuthorization struct + Raw string + Token string + Type string + type LogLevel int + const DEFAULT_LOG_PREFIX + const DEFAULT_LOG_TIME_FORMAT + const LogLevelDebug + const LogLevelError + const LogLevelFatal + const LogLevelInfo + const LogLevelWarn + type Logger interface + Debug func(v ...interface{}) + Debugf func(format string, v ...interface{}) + Error func(v ...interface{}) + Errorf func(format string, v ...interface{}) + Fatal func(v ...interface{}) + Fatalf func(format string, v ...interface{}) + Info func(v ...interface{}) + Infof func(format string, v ...interface{}) + Print func(v ...interface{}) + Printf func(format string, v ...interface{}) + Warn func(v ...interface{}) + Warnf func(format string, v ...interface{}) + func NewDefaultLogger(config ...*DefaultLoggerConfig) Logger + type MedaContext interface + Bind func(interface{}) error + BindForm func(interface{}) error + BindJSON func(interface{}) error + Context func() context.Context + Get func(key string) interface{} + GetBody func() []byte + GetFile func(fieldName string) (*multipart.FileHeader, error) + GetHeader func(key string) string + GetHeaders func() *RequestHeader + GetMethod func() string + GetPath func() string + GetQueryParam func(key string) string + GetQueryParams func() map[string][]string + JSON func(code int, data interface{}) error + Request func() *http.Request + Response func() http.ResponseWriter + SaveFile func(file *multipart.FileHeader, dst string) error + SendFile func(filepath string, attachment bool) error + Set func(key string, value interface{}) + SetContext func(ctx context.Context) + SetHeader func(key, value string) + SetRequestHeader func(key, value string) + SetResponseHeader func(key, value string) + Stream func(code int, contentType string, reader io.Reader) error + String func(code int, data string) error + Upgrade func() (MedaWebsocket, error) + type MedaError struct + Code int + Details interface{} + Message string + func NewError(code int, message string, details ...interface{}) *MedaError + func (e *MedaError) Error() string + type MedaHandlerFunc func(MedaContext) error + type MedaMiddleware interface + Handle func(MedaHandlerFunc) MedaHandlerFunc + Name func() string + func MiddlewareBasicAuth(username, password string) MedaMiddleware + func MiddlewareCORS(config *CORSConfig) MedaMiddleware + func MiddlewareCache(config CacheConfig) MedaMiddleware + func MiddlewareCompress(config CompressionConfig) MedaMiddleware + func MiddlewareHeaderParser() MedaMiddleware + func MiddlewareLogger(log Logger) MedaMiddleware + func MiddlewareRateLimiter(config RateLimitConfig) MedaMiddleware + func MiddlewareRecover(config ...RecoverConfig) MedaMiddleware + func MiddlewareRequestID() MedaMiddleware + func MiddlewareSecurity(config SecurityConfig) MedaMiddleware + func MiddlewareTimeout(config TimeOutConfig) MedaMiddleware + type MedaMiddlewareFunc func(MedaHandlerFunc) MedaHandlerFunc + func BasicAuth(username, password string) MedaMiddlewareFunc + func CORS(config *CORSConfig) MedaMiddlewareFunc + func Compress(config CompressionConfig) MedaMiddlewareFunc + func HeaderParser() MedaMiddlewareFunc + func RateLimiter(config RateLimitConfig) MedaMiddlewareFunc + func Recover(config ...RecoverConfig) MedaMiddlewareFunc + func RequestID() MedaMiddlewareFunc + func Security(config SecurityConfig) MedaMiddlewareFunc + func SimpleCache(config CacheConfig) MedaMiddlewareFunc + func SimpleLog(log Logger) MedaMiddlewareFunc + func Timeout(config TimeOutConfig) MedaMiddlewareFunc + type MedaRouter interface + DELETE func(path string, handler MedaHandlerFunc) + GET func(path string, handler MedaHandlerFunc) + Group func(prefix string) MedaRouter + HEAD func(path string, handler MedaHandlerFunc) + OPTIONS func(path string, handler MedaHandlerFunc) + PATCH func(path string, handler MedaHandlerFunc) + POST func(path string, handler MedaHandlerFunc) + PUT func(path string, handler MedaHandlerFunc) + Static func(prefix, root string) + StaticFile func(path, filepath string) + Use func(middleware ...MedaMiddleware) + WebSocket func(path string, handler func(MedaWebsocket) error) + func CreateInternalAPI(s MedaServer) MedaRouter + type MedaServer interface + Shutdown func(ctx context.Context) error + Start func(address string) error + type MedaWebsocket interface + Close func() error + ReadJSON func(v interface{}) error + ReadMessage func() (messageType int, p []byte, err error) + WriteJSON func(v interface{}) error + WriteMessage func(messageType int, data []byte) error + type MemoryCache struct + func (c *MemoryCache) Clear() error + func (c *MemoryCache) Delete(key string) error + func (c *MemoryCache) Get(key string) (interface{}, bool) + func (c *MemoryCache) Set(key string, value interface{}, ttl time.Duration) error + type MemorySession struct + func (s *MemorySession) Clear() error + func (s *MemorySession) Delete(key string) error + func (s *MemorySession) Get(key string) interface{} + func (s *MemorySession) ID() string + func (s *MemorySession) Save() error + func (s *MemorySession) Set(key string, value interface{}) error + type NamedMiddleware struct + func WithName(name string, m MedaMiddlewareFunc) NamedMiddleware + func (m NamedMiddleware) Name() string + func (n NamedMiddleware) Handle(next MedaHandlerFunc) MedaHandlerFunc + type RateLimit struct + func (rl *RateLimit) Allow(key string) error + type RateLimitConfig struct + BurstSize int + ClientTimeout time.Duration + KeyFunc func(MedaContext) string + RequestsPerSecond int + type RecoverConfig struct + ErrorHandler func(c MedaContext, err interface{}, stack []byte) error + LogStackTrace bool + Logger Logger + StackTrace bool + type RequestHeader struct + APIKey string + AcceptType string + Authorization HeaderAuthorization + Browser string + BrowserVersion string + Code string + ConnectingIP string + Device string + ForwardedFor string + Origin string + Platform string + PlatformOS string + PlatformOSVersion string + PrivateToken string + RealIP string + RemoteIP string + RequestID string + TraceID string + TrueIP string + UserAgent string + func (mh *RequestHeader) FromHttpRequest(stdRequest *http.Request) + func (mh *RequestHeader) IP() string + type Routes struct + EndPoint string + Methods []string + func (r *Routes) Sprint() string + type SecurityConfig struct + AllowedHosts []string + BrowserXssFilter bool + ContentSecurityPolicy string + ContentTypeNosniff bool + FrameDeny bool + SSLHost string + SSLRedirect bool + STSIncludeSubdomains bool + STSSeconds int64 + type Session interface + Clear func() error + Delete func(key string) error + Get func(key string) interface{} + ID func() string + Save func() error + Set func(key string, value interface{}) error + func NewMemorySession(id string) Session + type TimeOutConfig struct + IdleTimeout time.Duration + ReadTimeout time.Duration + WriteTimeout time.Duration