NAME

WWW::Gitea::Role::HTTP - HTTP + token/basic auth role for the Gitea REST API

VERSION

version 0.001

SYNOPSIS

package WWW::Gitea;
use Moo;

has api_url  => ( is => 'lazy' );
has token    => ( is => 'ro' );
has username => ( is => 'ro' );
has password => ( is => 'ro' );

with 'WWW::Gitea::Role::HTTP';

# Now: $self->request(POST => '/repos/getty/foo/issues', body => \%payload);

DESCRIPTION

HTTP transport role consumed by WWW::Gitea. Builds and executes JSON requests against a Gitea instance's api/v1 endpoint and applies authentication: a personal access token (Authorization: token ...) when a "token" is set, otherwise HTTP Basic with "username" + "password".

The role requires its consumer to provide api_url, token, username and password (the latter three may be undef for anonymous access to public endpoints).

ua

The LWP::UserAgent instance used for all HTTP traffic.

request

my $data = $self->request('POST', '/repos/getty/foo/issues', body => \%payload);

Low-level request method used by the API controllers. Accepts body, query, headers and content_type named arguments. Returns the decoded JSON response (or 1 for an empty 2xx such as 204 No Content); croaks with the Gitea error message on a non-2xx response.

request_status

my $code = $self->request_status('GET', '/repos/getty/foo/pulls/1/merge');

Sends a request and returns only the numeric HTTP status code, without croaking on a non-2xx response. Used for status-only endpoints such as the pull-request "is merged" check (204 merged, 404 not merged).

SEE ALSO

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://codeberg.org/getty/p5-www-gitea/issues.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHOR

Torsten Raudssus <torsten@raudssus.de> https://raudssus.de/

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by Torsten Raudssus.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.