fetcher

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2026 License: MIT Imports: 13 Imported by: 0

README

gitpanda_fetcher

Module for parsing GitLab™ URLs and retrieving information via GitLab API

GITLAB is a trademark of GitLab Inc. in the United States and other countries and regions

test

Usage

package main

import (
	"github.com/sue445/gitpanda_fetcher"
)

func main() {
	client, err := fetcher.NewClient(&fetcher.ClientParams{
		APIEndpoint:    "https://gitlab.example.com/api/v4",
		BaseURL:        "https://gitlab.example.com",
		PrivateToken:   "xxxxxxxxxx",
		IsDebugLogging: true,
	})

	page, err := client.FetchURL("https://gitlab.example.com/user/repo/-/merge_requests/123")
}

Requirements

  • GitLab API v4

Supported URL format

  • User URL
    • e.g. ${GITLAB_BASE_URL}/:username
  • Group URL
    • e.g. ${GITLAB_BASE_URL}/:groupname
  • Project URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame
  • Issue URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/issues/:iid
  • MergeRequest URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/merge_requests/:iid
  • Job URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/-/jobs/:id
  • Pipeline URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/pipelines/:id
  • Blob URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/blob/:sha1/:filename
  • Commit URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/commit/:sha1
  • Project snippet URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/snippets/:id
  • Snippet URL
    • e.g. ${GITLAB_BASE_URL}/snippets/:id
  • Epic URL
    • e.g. ${GITLAB_BASE_URL}/groups/:groupname/-/epics/:iid
  • Work item URL
    • e.g. ${GITLAB_BASE_URL}/:namespace/:reponame/-/work_items/:iid

Documentation

Overview

Package gitpanda_fetcher parses GitLab URLs and retrieves data via the GitLab API

Index

Constants

View Source
const BrandColor = "#fc6d26" // https://brandcolors.net/b/gitlab

BrandColor represents GitLab color

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents GitLab URL parser

func NewClient

func NewClient(params *ClientParams) (*Client, error)

NewClient create new Client instance

func (*Client) FetchURL

func (p *Client) FetchURL(url string) (*Page, error)

FetchURL fetch GitLab url

type ClientParams

type ClientParams struct {
	APIEndpoint    string
	BaseURL        string
	PrivateToken   string
	UserAgent      string
	IsDebugLogging bool
	HTTPClient     *http.Client
}

ClientParams represents parameters of NewClient

type Page

type Page struct {
	Title                  string
	Description            string
	AuthorName             string
	AuthorAvatarURL        string
	AvatarURL              string
	CanTruncateDescription bool
	FooterTitle            string
	FooterURL              string
	FooterTime             *time.Time
	Color                  string
}

Page represents info of GitLab page

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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