Home / File/ redirect.go — gin Source File

redirect.go — gin Source File

Architecture documentation for redirect.go, a go file in the gin codebase. 1 imports, 0 dependents.

File go 1 imports

Entity Profile

Dependency Diagram

graph LR
  b3973abb_05af_00a5_2753_822e28560da3["redirect.go"]
  e8c9ceab_299a_1e0e_919f_ddb404deb199["fmt"]
  b3973abb_05af_00a5_2753_822e28560da3 --> e8c9ceab_299a_1e0e_919f_ddb404deb199
  style b3973abb_05af_00a5_2753_822e28560da3 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.

package render

import (
	"fmt"
	"net/http"
)

// Redirect contains the http request reference and redirects status code and location.
type Redirect struct {
	Code     int
	Request  *http.Request
	Location string
}

// Render (Redirect) redirects the http request to new location and writes redirect response.
func (r Redirect) Render(w http.ResponseWriter) error {
	if (r.Code < http.StatusMultipleChoices || r.Code > http.StatusPermanentRedirect) && r.Code != http.StatusCreated {
		panic(fmt.Sprintf("Cannot redirect with status code %d", r.Code))
	}
	http.Redirect(w, r.Request, r.Location, r.Code)
	return nil
}

// WriteContentType (Redirect) don't write any ContentType.
func (r Redirect) WriteContentType(http.ResponseWriter) {}

Types

Dependencies

  • fmt

Frequently Asked Questions

What does redirect.go do?
redirect.go is a source file in the gin codebase, written in go.
What does redirect.go depend on?
redirect.go imports 1 module(s): fmt.
Where is redirect.go in the architecture?
redirect.go is located at render/redirect.go (directory: render).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free