GorimGorim
  • Introduction
  • Getting Started
  • Configuration
  • Routing
  • Middleware
  • Serializers
  • Views
  • Mixins
  • Filter
  • Pagination
  • Permissions
  • Migrations
  • Error Handling
GitHub
  • Introduction
  • Getting Started
  • Configuration
  • Routing
  • Middleware
  • Serializers
  • Views
  • Mixins
  • Filter
  • Pagination
  • Permissions
  • Migrations
  • Error Handling
GitHub
  • Guide

    • Introduction
    • Getting Started
    • Serializers
    • Views
    • Mixins
    • Filter
    • Pagination
    • Routing
    • Middleware
      • Basic Usage
      • Built-in Middleware
        • RecoverMiddleware
        • LoggerMiddleware
        • AuthenticationMiddleware
    • Permissions
    • Migrations
    • Error Handling

Middleware

Gorim uses struct-based middleware.

Basic Usage

import (
	"gorim.org/gorim/middlewares"
)

type MyMiddleware struct {
    middlewares.BaseMiddleware
}
func (m *MyMiddleware) Call(c gorim.Context) error {
    // Your middleware logic here
    return nil
}

Built-in Middleware

Gorim provides some built-in middleware:

RecoverMiddleware

The RecoverMiddleware is a middleware that recovers from panics and returns a 500 error.

LoggerMiddleware

The LoggerMiddleware is a middleware that logs the request and response in the console.

AuthenticationMiddleware

The AuthenticationMiddleware is a middleware that authenticates the request.

Edit this page
Last Updated:
Contributors: Rimba Prayoga
Prev
Routing
Next
Permissions