Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
366f865e
Commit
366f865e
authored
Jun 07, 2023
by
Will Cory
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
linter
parent
e9ab2181
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
3 deletions
+10
-3
api.go
indexer/api/api.go
+10
-3
No files found.
indexer/api/api.go
View file @
366f865e
...
@@ -2,10 +2,12 @@ package api
...
@@ -2,10 +2,12 @@ package api
import
(
import
(
"encoding/json"
"encoding/json"
"log"
"net/http"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum-optimism/optimism/indexer/database"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common"
"github.com/go-chi/chi"
"github.com/go-chi/chi"
"net/http"
)
)
type
PaginationResponse
struct
{
type
PaginationResponse
struct
{
...
@@ -72,7 +74,9 @@ func (a *Api) WithdrawalsHandler(w http.ResponseWriter, r *http.Request) {
...
@@ -72,7 +74,9 @@ func (a *Api) WithdrawalsHandler(w http.ResponseWriter, r *http.Request) {
func
jsonResponse
(
w
http
.
ResponseWriter
,
data
interface
{},
statusCode
int
)
{
func
jsonResponse
(
w
http
.
ResponseWriter
,
data
interface
{},
statusCode
int
)
{
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"Content-Type"
,
"application/json"
)
w
.
WriteHeader
(
statusCode
)
w
.
WriteHeader
(
statusCode
)
json
.
NewEncoder
(
w
)
.
Encode
(
data
)
if
err
:=
json
.
NewEncoder
(
w
)
.
Encode
(
data
);
err
!=
nil
{
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusInternalServerError
)
}
}
}
type
Api
struct
{
type
Api
struct
{
...
@@ -98,5 +102,8 @@ func NewApi(bv database.BridgeView) *Api {
...
@@ -98,5 +102,8 @@ func NewApi(bv database.BridgeView) *Api {
}
}
func
(
a
*
Api
)
Listen
(
port
string
)
{
func
(
a
*
Api
)
Listen
(
port
string
)
{
http
.
ListenAndServe
(
port
,
a
.
Router
)
err
:=
http
.
ListenAndServe
(
port
,
a
.
Router
)
if
err
!=
nil
{
log
.
Fatal
(
"Http server failed to start listening"
,
err
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment